How can I prevent a QDialog in PyQt from being resizeable or maximazable? I don't want the window's size changed.
Asked
Active
Viewed 4.8k times
3 Answers
75
Use setFixedSize:
mydialog.setFixedSize(width, height)

Avaris
- 35,883
- 7
- 81
- 72
-
44`self.setFixedSize(self.size())` to set it to always be the current size – Claudiu Dec 22 '16 at 07:45
5
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....

Amin Matola
- 137
- 2
- 7
0
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)

anoopknr
- 3,177
- 2
- 23
- 33