pyqt的gui界面禁止最大化
时间: 2023-07-05 16:20:35 浏览: 181
要禁止PyQt GUI界面最大化,你可以在你的代码中使用setFixedSize()方法来设置一个固定的窗口大小,这样用户就无法最大化窗口。这个方法需要传递两个参数,分别是窗口的宽度和高度。例如,下面的代码将创建一个大小为400x300像素的窗口,并禁止最大化:
```python
import sys
from PyQt5.QtWidgets import QApplication, QWidget
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.setGeometry(300, 300, 400, 300)
self.setFixedSize(400, 300)
self.setWindowTitle('禁止最大化窗口')
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
```
在上面的代码中,setGeometry()方法设置了窗口的位置和大小,而setFixedSize()方法将窗口大小设置为固定的400x300像素。最后,调用show()方法显示窗口并调用app.exec_()方法进入主循环。
阅读全文
相关推荐
















