PyQt: Prevent Resize and Maximize in QDialog? PyQt: Prevent Resize and Maximize in QDialog? python python

PyQt: Prevent Resize and Maximize in QDialog?


Use setFixedSize:

mydialog.setFixedSize(width, height)


The above answers are just fine,besides, you could set maximum and mini widths and heights manually,like this:

myDialog = QDialog()myDialog.setMaximumWidth(myDialog.width())myDialog.setMaximumHeight(myDialog.height())

or in short, you could use maximumSize as:

myDialog.setMaximumSize()

Just as in the above code....


To set fixed sized window or dialog box (QWidget in general) you could use setFixedSize(QSize) or setFixedSize(int, int) functions.

In PyQt5, use :-

custom_dialog.setFixedSize(QSize(width, height)) # setFixedSize(QSize)

or

custom_dialog.setFixedSize(width, height) # setFixedSize(int, int)

You must import

from PyQt5.QtCore import  QSize

You could also use

custom_dialog.setFixedSize(custom_dialog.size())

Other Related Functions

setFixedWidth(int)

setFixedHeight(int)