PyQt4创建不可调整的窗口(PyQt4 create windows that are unresizable)

编程入门 行业动态 更新时间:2024-10-27 13:28:49
PyQt4创建不可调整的窗口(PyQt4 create windows that are unresizable)

出于某种原因,我使用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!

更多推荐

本文发布于:2023-07-17 10:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1142817.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:窗口   create   unresizable   windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!