Pregunta

How can I prevent a QDialog in PyQt from being resizeable or maximazable? I don't want the window's size changed.

¿Fue útil?

Solución

Use setFixedSize:

mydialog.setFixedSize(width, height)

Otros consejos

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)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top