[Qgis-developer] OT: qtdesigner problems: generated ui file not valid for pyuic4

Matthew Perry perrygeo at gmail.com
Thu Oct 4 16:29:45 EDT 2007


Hi folks,

 Not a qgis question per se but I figured that someone on this list
might have encountered this and/or come up with a solution.

 It appears that designer-qt4 is generating ui files that are not
compatible with pyuic4. I'm using straight ubuntu fiesty packages for
all the qt software.

 Basic problem is that simply opening and saving a ui file in qt
designer (making no changes at all) messes up a previously valid ui
file. The example below shows the details.

Has anyone else encountered this issue on ubuntu? Am I doing something
obviously wrong here? Any ideas on how to fix this?

-----------------------------------------------------
cp mainwindow.ui mainwindow.orig.ui
cp mainwindow_ui.py mainwindow_ui.orig.py
make clean

# generate the python file from the untouched ui file
pyuic4 -d -o mainwindow_ui.py mainwindow.ui
# OK; still runs fine

diff mainwindow_ui.py mainwindow_ui.orig.py
5c5
< # Created: Thu Oct  4 13:17:24 2007
---
> # Created: Wed Oct  3 09:44:22 2007


# open qt4 deisgner
designer-qt4 mainwindow.ui
# Change NOTHING, just file > save

# compile with pyuic4
pyuic4 -d -o mainwindow_ui.py mainwindow.ui
Traceback (most recent call last):
  File "/usr/bin/pyuic4", line 65, in <module>
    error = generateUi(args[1], options.output, options.execute, options.indent)
  File "/usr/bin/pyuic4", line 28, in generateUi
    uic.compileUi(uifname, pyfile, execute, indent)
  File "/usr/lib/python2.5/site-packages/PyQt4/uic/__init__.py", line
56, in compileUi
    winfo = compiler.UICompiler().compileUi(uifile, pyfile)
  File "/usr/lib/python2.5/site-packages/PyQt4/uic/Compiler/compiler.py",
line 71, in compileUi
    w = self.parse(input_stream)
  File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line
524, in parse
    actor(elem)
  File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line
372, in createUserInterface
    self.traverseWidgetTree(elem)
  File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line
349, in traverseWidgetTree
    handler(self, child)
  File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line
165, in createWidget
    self.traverseWidgetTree(elem)
  File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line
349, in traverseWidgetTree
    handler(self, child)
  File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line
240, in createLayout
    self.traverseWidgetTree(elem)
  File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line
349, in traverseWidgetTree
    handler(self, child)
  File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line
249, in handleItem
    self.traverseWidgetTree(elem)
  File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line
349, in traverseWidgetTree
    handler(self, child)
  File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line
165, in createWidget
    self.traverseWidgetTree(elem)
  File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line
349, in traverseWidgetTree
    handler(self, child)
  File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line
158, in createWidget
    self.stack.push(self.setupObject(widgetClass(elem), parent, elem))
  File "/usr/lib/python2.5/site-packages/PyQt4/uic/uiparser.py", line
133, in setupObject
    self.wprops.setProperties(obj, branch)
  File "/usr/lib/python2.5/site-packages/PyQt4/uic/properties.py",
line 189, in setProperties
    self.convert(prop, widget))
  File "/usr/lib/python2.5/site-packages/PyQt4/uic/properties.py",
line 156, in convert
    return func(prop[0], **args)
  File "/usr/lib/python2.5/site-packages/PyQt4/uic/properties.py",
line 116, in _sizepolicy
    sizePolicy.setHorizontalStretch(values[2])
IndexError: list index out of range

# show differences in ui file due to saving with qt4 designer
diff mainwindow.ui mainwindow.orig.ui
17c17
<     <property name="leftMargin" >
---
>     <property name="margin" >
20,32c20
<     <property name="topMargin" >
<      <number>9</number>
<     </property>
<     <property name="rightMargin" >
<      <number>9</number>
<     </property>
<     <property name="bottomMargin" >
<      <number>9</number>
<     </property>
<     <property name="horizontalSpacing" >
<      <number>6</number>
<     </property>
<     <property name="verticalSpacing" >
---
>     <property name="spacing" >
45c33,35
<         <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
---
>         <sizepolicy>
>          <hsizetype>5</hsizetype>
>          <vsizetype>5</vsizetype>
64,65c54,55
<           <width>405</width>
<           <height>573</height>
---
>           <width>353</width>
>           <height>583</height>
72c62
<          <property name="leftMargin" >
---
>          <property name="margin" >
75,87c65
<          <property name="topMargin" >
<           <number>9</number>
<          </property>
<          <property name="rightMargin" >
<           <number>9</number>
<          </property>
<          <property name="bottomMargin" >
<           <number>9</number>
<          </property>
<          <property name="horizontalSpacing" >
<           <number>6</number>
<          </property>
<          <property name="verticalSpacing" >
---
>          <property name="spacing" >
118c96,98
<         <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
---
>         <sizepolicy>
>          <hsizetype>5</hsizetype>
>          <vsizetype>5</vsizetype>
140c120
<      <height>25</height>
---
>      <height>24</height>



-- 
Matthew T. Perry
http://www.perrygeo.net

"Never ascribe to malice, that which can be adequately explained by
incompetence."



More information about the Qgis-developer mailing list