[PyQt] PyQt4.uic.loadUi fail to load QTableWidget containing items

Yann Cointepas yann at sapetnioc.org
Wed Apr 28 16:53:58 BST 2010


 With PyQt 4.7.2 (Qt 4.6.2, sip 4.10), it is not possible to load the
attached ui file. The problem happens whenever a value is inserted in a
QTableWidget with designer. It used to work with PyQt 4.3.3.

The following code (used in IPython):

from PyQt4.uic import loadUi
from PyQt4.QtGui import QWidget
w= QWidget()
loadUi( '/tmp/test.ui', w )

raises the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/yc176684/<ipython console> in <module>()

/i2bm/research/Mandriva-2008.0-i686/python/lib/python2.5/site-packages/PyQt4/uic/__init__.py
in loadUi(uifile, baseinstance)
    175     from PyQt4.uic.Loader.loader import DynamicUILoader
    176
--> 177     return DynamicUILoader().loadUi(uifile, baseinstance)
    178
    179

/i2bm/research/Mandriva-2008.0-i686/python/lib/python2.5/site-packages/PyQt4/uic/Loader/loader.py
in loadUi(self, filename, toplevelInst)
     17             return self.factory.createQObject(classname, widgetname,
())
     18
     19     def loadUi(self, filename, toplevelInst = None):
     20         self.toplevelInst = toplevelInst
---> 21         return self.parse(filename)

/i2bm/research/Mandriva-2008.0-i686/python/lib/python2.5/site-packages/PyQt4/uic/uiparser.py
in parse(self, filename)
    811             elem = document.find(tagname)
    812             if elem is not None:
--> 813                 actor(elem)
    814         self.finalize()
    815         w = self.toplevelWidget

/i2bm/research/Mandriva-2008.0-i686/python/lib/python2.5/site-packages/PyQt4/uic/uiparser.py
in createUserInterface(self, elem)
    659         self.wprops.setProperties(self.toplevelWidget, elem)
    660         self.stack.push(self.toplevelWidget)
--> 661         self.traverseWidgetTree(elem)
    662         self.stack.popWidget()
    663         self.addActions()

/i2bm/research/Mandriva-2008.0-i686/python/lib/python2.5/site-packages/PyQt4/uic/uiparser.py
in traverseWidgetTree(self, elem)
    637                 continue
    638
--> 639             handler(self, child)
    640
    641     def createUserInterface(self, elem):

/i2bm/research/Mandriva-2008.0-i686/python/lib/python2.5/site-packages/PyQt4/uic/uiparser.py
in createWidget(self, elem)
    167
self.stack.topwidget.setRowCount(len(elem.findall("row")))
    168
--> 169         self.traverseWidgetTree(elem)
    170         widget = self.stack.popWidget()
    171

/i2bm/research/Mandriva-2008.0-i686/python/lib/python2.5/site-packages/PyQt4/uic/uiparser.py
in traverseWidgetTree(self, elem)
    637                 continue
    638
--> 639             handler(self, child)
    640
    641     def createUserInterface(self, elem):

/i2bm/research/Mandriva-2008.0-i686/python/lib/python2.5/site-packages/PyQt4/uic/uiparser.py
in handleItem(self, elem)
    544
    545                 if text:
--> 546                     w.item(row, col).setText(text)
    547
    548                 if icon:

AttributeError: 'NoneType' object has no attribute 'setText'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100428/4fe46539/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.ui
Type: application/x-designer
Size: 879 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100428/4fe46539/attachment-0001.bin>


More information about the PyQt mailing list