Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/351.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使Qt设计器自动调整布局与Pyqt4一起工作?_Python_Qt_Pyqt_Designer_Pyqt4 - Fatal编程技术网

Python 如何使Qt设计器自动调整布局与Pyqt4一起工作?

Python 如何使Qt设计器自动调整布局与Pyqt4一起工作?,python,qt,pyqt,designer,pyqt4,Python,Qt,Pyqt,Designer,Pyqt4,我正在尝试使用Qt Designer和Pyqt4的一个简单示例,当我在Qt Designer control+R中预览UI时,它看起来不错,但是当我尝试执行生成的UI代码时,布局无法正常工作,并且没有将小部件自动调整到最大值,它们太小,无法使用 如果我使用固定尺寸,效果很好 用于加载窗口的代码为: import sys from PyQt4 import QtCore, QtGui from table import Ui_table class Main(QtGui.QMainWindo

我正在尝试使用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

这是一个很长的目标,但不是使用QMainWindow和XML ui描述定义QWidget的代码。我不确定这是否是问题所在,但在我看来它并不是100%正确的