我正在尝试使用 Qt Designer 和 Pyqt4 的一个简单示例,当我在 Qt Designer (control+R) 中预览 UI 时,它看起来不错,但是当我尝试执行生成的 UI 代码时,布局无法正常工作,而不是将小部件自动调整到最大值,它们太小以至于无法使用。
如果我使用固定尺寸,效果很好。
用于加载窗口的代码是:
import sys
from PyQt4 import QtCore, QtGui
from table import Ui_table
class Main(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.ui = Ui_table()
self.ui.setupUi(self)
def main():
app = QtGui.QApplication(sys.argv)
window=Main()
window.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()
Qt Designer xml 文件用于生成带有最大化的简单小部件的 ui 代码:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>table</class>
<widget class="QWidget" name="table">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>457</width>
<height>422</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTreeWidget" name="list">
<column>
<property name="text">
<string>name</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
有什么建议么?
操作系统:Windows XP
Python:Python 2.6.3
PyQt4:4.6.1