0
나는 Qt Designer와 Pyqt4로 간단한 예제를 만들고 있는데, Qt Designer (control + R)에서 UI를 미리 볼 때 모양이 좋아 보이지만 생성 된 UI 코드를 실행하려고하면 레이아웃이 제대로 작동하지 않으며 위젯을 최대 크기로 자동 크기 지정하는 대신 사용하기에 너무 작습니다.Qt 디자이너가 자동 크기 조정 레이아웃을 Pyqt4와 함께 사용하려면 어떻게해야합니까?
고정 된 크기를 사용하면 잘 작동합니다.
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는 디자이너 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>
어떤 제안?
OS : 윈도우 XP
파이썬 : 파이썬 2.6.3
PyQt4는 : 4.6.1