How can I get rid of the resize handle in QDialog?

I have the following class:

class SelectDateDialog(QDialog):
    startDate = date.today()
    endDate = date.today()

    def __init__(self, text, isInterval = False):
        QDialog.__init__(self)
        uic.loadUi("resources/SelectDate.ui", self)

Now the dialog box can be changed in Mac OS X 10.5, but this should not be. It has a resizing knob in the lower right.

I already tried the function setSizeGripEnabled, it did not change anything.

How can I make it immutable?

+3
source share
4 answers

if you want not to resize the QDialog dlg then set

dlg.setWindowFlags(Qt::MSWindowsFixedSizeDialogHint);
+8
source

I use the following code to fix the size QDialog:

layout()->setSizeConstraint( QLayout::SetFixedSize ) ;
setSizeGripEnabled( false ) ;

The first line provides the layout size based on the preferred size of the widgets contained in the layout. The second line deletes the actual capture.

, .

+5

- QLayout.SetFixedSize( QLayout:: SetFixedSize ++). - , .

, Qt Designer . .ui , , "". layoutSizeConstraint SetFixedSize.

, , .

+4

For some reason, I always had to do the following (in Qt Designer) to be absolutely sure that the window cannot be resized:

sizePolicy -> Horizontal Policy = Fixed
sizePolicy -> Vertical Policy = Fixed

minimumSize -> Width = X
minimumSize -> Height = Y

maximumSize -> Width = X
maximumSize -> Height = Y

Note that I chose X and Y to show that minimumSize == maximumSize . When you do this, the resize descriptor should disappear on its own, although I saw that at least one Linux distribution left the descriptor. In this particular case, we simply hid the handle, since it could not resize the window.

+1
source

Source: https://habr.com/ru/post/1703650/


All Articles