How to block the resizing of a widget / window?

3

I'm setting a particular widget according to the size of the secondary monitor.

This I was able to do perfectly. However, since I'm new to PyQt, I'd like to know how to block the resizing of the window.

I mean, I want the user not to be able to maximize, minimize, or resize this widget.

How can I do this?

Current code:

from PyQt4 import QtCore, QtGui

class RetroProjetorWindow(QtGui.QWidget):
    def __init__(self, desktop, parent=None):
        super(RetroProjetorWindow, self).__init__(parent)
        self.setupUi(desktop)

    def setupUi(self, desktop):
        self.setGeometry(desktop.screenGeometry(1))
        # Quero bloquear o redimensionamento aqui...
    
asked by anonymous 17.10.2016 / 18:14

1 answer

4

Just keep the minimum and maximum

self.setFixedSize(200, 200);

Variations:

setFixedHeight (self, int h)
setFixedSize (self, QSize)
setFixedSize (self, int w, int h)
setFixedWidth (self, int w)

You can use something like (this would be preferable to limit between a range):

self.setMinimumSize(200, 200)
self.setMaximumSize(300, 240)

Being able to use variations like:

setMaximumHeight (self, int maxh)
setMaximumSize (self, int maxw, int maxh)
setMaximumSize (self, QSize s)
setMaximumWidth (self, int maxw)
setMinimumHeight (self, int minh)
setMinimumSize (self, int minw, int minh)
setMinimumSize (self, QSize s)
setMinimumWidth (self, int minw)

I think to use QDesktop you should do something like (in this case I used desktop.primaryScreen to get the main monitor, this may vary):

 screenSize = desktop.availableGeometry(desktop.primaryScreen())
 self.setGeometry(screenSize)

You can change desktop.primaryScreen() to desktop.screen(0) or as needed.

Documentation: link

    
17.10.2016 / 18:24