[英]PyQt: Prevent Resize and Maximize in QDialog?
How can I prevent a QDialog in PyQt from being resizeable or maximazable? 如何防止PyQt中的QDialog可调整大小或最大化? I don't want the window's size changed.
我不希望窗口的大小发生变化。
使用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: 或者简而言之,您可以使用maximumSize:
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. 要设置固定大小的 窗口或对话框 ( 通常为QWidget ),可以使用setFixedSize ( QSize )或setFixedSize(int,int)函数。
In PyQt5, use :- 在PyQt5中,使用: -
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) setFixedWidth (int)
setFixedHeight (int) setFixedHeight (int)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.