Qt Designer と Pyqt4 で簡単な例を試しています。Qt Designer で UI をプレビューすると (コントロール + R)、見た目は良いのですが、生成された 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()
また、単純なウィジェットを最大化して ui コードを生成するための Qt Designer xml ファイル:
<?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>
助言がありますか?
OS: Windows XP
Python: Python 2.6.3
PyQt4: 4.6.1