出于某种原因,我使用PyQt4创建的任何小部件都无法调整大小。 当我尝试用鼠标调整窗口大小时没有任何反应。 以下简单程序在我的机器上重现此行为:
from PyQt4.QtGui import QMainWindow, QApplication from sys import argv app = QApplication(argv) mw = QMainWindow() app.exec_()我通常使用C ++ Qt库开发,我希望这可以工作。 更重要的是,等效C ++应用程序的行为方式完全相同。
什么可能导致这个?
For some reason, any widget I create using PyQt4 cannot be resized. When i try and resize the window with the mouse nothing happens. The following simple program reproduces this behavior on my machine:
from PyQt4.QtGui import QMainWindow, QApplication from sys import argv app = QApplication(argv) mw = QMainWindow() app.exec_()I usually develop using the C++ Qt libraries, where I would expect this to work. What's more an equivilent C++ application behaves in exactly the same way.
What could cause this?
最满意答案
exec之前的mw.setGeometry(0, 0, 640, 480) 。 它在屏幕上定位窗口(第一个参数),调整它的大小(3和4参数)并启用大小调整。
I have found the solution - it turns out I had broken my compiz settings in a rather... unique manner, which caused Qt apps to not resize correctly. Thanks to everyone who answered however!
更多推荐
发布评论