[PyQt] Problem using QFormLayout in QtDesigner and pyuic4 in qt 4.4

Pavol Mravec palo at ksp.sk
Tue May 27 14:47:29 BST 2008


When I use a QFormLayout in QtDesigner and generate python module
using pyuic4, pyuic4 finishes with error: Unknown Qt widget:
QFormLayout. I use qt 4.4 on windows xp compiled with msvs 2008
express edition and pyqt 4.4.2. The expected result is a working
generated python module. When I switch from QFormLayout to
QGridLayout, everything works correctly.

Pavol Mravec

Example pyuic4 output: pyuic4 widget.ui

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'widget.ui'
#
# Created: Tue May 27 15:41:56 2008
#      by: PyQt4 UI code generator 4.4.2
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui

class Ui_gbConn(object):
    def setupUi(self, gbConn):
        gbConn.setObjectName("gbConn")
        gbConn.resize(340,139)
        sizePolicy =
QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum,QtGui.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(gbConn.sizePolicy().hasHeightForWidth())
        gbConn.setSizePolicy(sizePolicy)
        self.verticalLayout = QtGui.QVBoxLayout(gbConn)
        self.verticalLayout.setObjectName("verticalLayout")
Unknown Qt widget: QFormLayout

Example input ui file:

<ui version="4.0" >
 <class>gbConn</class>
 <widget class="QGroupBox" name="gbConn" >
  <property name="geometry" >
   <rect>
    <x>0</x>
    <y>0</y>
    <width>340</width>
    <height>139</height>
   </rect>
  </property>
  <property name="sizePolicy" >
   <sizepolicy vsizetype="Maximum" hsizetype="Maximum" >
    <horstretch>0</horstretch>
    <verstretch>0</verstretch>
   </sizepolicy>
  </property>
  <property name="windowTitle" >
   <string>Form</string>
  </property>
  <property name="title" >
   <string>Connection</string>
  </property>
  <layout class="QVBoxLayout" name="verticalLayout" >
   <item>
    <layout class="QFormLayout" name="formLayout" >
     <item row="0" column="0" >
      <widget class="QLabel" name="lblAddress" >
       <property name="text" >
        <string>&amp;Address:</string>
       </property>
       <property name="buddy" >
        <cstring>leAddress</cstring>
       </property>
      </widget>
     </item>
     <item row="0" column="1" >
      <widget class="QLineEdit" name="leAddress" >
       <property name="text" >
        <string>192.168.1.102</string>
       </property>
      </widget>
     </item>
     <item row="1" column="0" >
      <widget class="QLabel" name="lblPort" >
       <property name="text" >
        <string>&amp;Port:</string>
       </property>
       <property name="buddy" >
        <cstring>sbPort</cstring>
       </property>
      </widget>
     </item>
     <item row="1" column="1" >
      <widget class="QSpinBox" name="sbPort" >
       <property name="minimum" >
        <number>1</number>
       </property>
       <property name="maximum" >
        <number>65535</number>
       </property>
       <property name="value" >
        <number>8010</number>
       </property>
      </widget>
     </item>
     <item row="2" column="0" >
      <widget class="QLabel" name="lblResult" >
       <property name="text" >
        <string>&amp;Response result:</string>
       </property>
       <property name="buddy" >
        <cstring>leResult</cstring>
       </property>
      </widget>
     </item>
     <item row="2" column="1" >
      <widget class="QLineEdit" name="leResult" >
       <property name="text" >
        <string>OK</string>
       </property>
      </widget>
     </item>
    </layout>
   </item>
   <item>
    <layout class="QHBoxLayout" name="horizontalLayout" >
     <item>
      <widget class="QPushButton" name="pbConnect" >
       <property name="text" >
        <string>&amp;Connect</string>
       </property>
      </widget>
     </item>
     <item>
      <widget class="QPushButton" name="pbDisconnect" >
       <property name="enabled" >
        <bool>false</bool>
       </property>
       <property name="text" >
        <string>&amp;Disconnect</string>
       </property>
      </widget>
     </item>
     <item>
      <widget class="QPushButton" name="pbLogon" >
       <property name="enabled" >
        <bool>false</bool>
       </property>
       <property name="text" >
        <string>Log o&amp;n</string>
       </property>
      </widget>
     </item>
     <item>
      <widget class="QPushButton" name="pbLogoff" >
       <property name="enabled" >
        <bool>false</bool>
       </property>
       <property name="text" >
        <string>Log o&amp;ff</string>
       </property>
      </widget>
     </item>
    </layout>
   </item>
  </layout>
 </widget>
 <tabstops>
  <tabstop>leAddress</tabstop>
  <tabstop>sbPort</tabstop>
  <tabstop>leResult</tabstop>
  <tabstop>pbConnect</tabstop>
  <tabstop>pbDisconnect</tabstop>
  <tabstop>pbLogon</tabstop>
  <tabstop>pbLogoff</tabstop>
 </tabstops>
 <resources/>
 <connections/>
</ui>


More information about the PyQt mailing list