How to block resizing a widget/window?

Asked

Viewed 1,079 times

3

I am setting a certain widget according to the size of the secondary monitor.

This I managed to do perfectly. However, as I am beginner with Pyqt, I would like to know how to block window resizing.

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

How can I do that?

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...

1 answer

4


Just get 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 preferred to limit between a range):

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

Can use variations as:

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 believe that to use the QDesktop you should do something like (in this case I used desktop.primaryScreen to catch the main monitor, this may vary):

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

You can change desktop.primaryScreen() for desktop.screen(0) or as required.

Documentation: http://pyqt.sourceforge.net/Docs/PyQt4/qwidget.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.