[PyQt] pyuic4 and QTreeWidget bug?

Arkadiusz Wahlig arkadiusz.wahlig at gmail.com
Fri May 8 13:39:17 BST 2009


Hi,

I have just started playing around with Qt Designer and PyQt4 and I
think I found a bug.

I'm using:

* Windows Vista Ultimate SP1 32bit,
* Python 2.6.2
* PyQt-Py2.6-gpl-4.4.4-2.exe

If I do the following:

* use the MainWindow template to create a project in Qt Designer,
* place a Tree Widget in the form,
* double-click the widget to bring up the items editor,
* click "+" to add a single element,
* click OK and save the *.ui file,
* use pyuic4 to convert the *ui to .py

Then I get the following output:

--------------------------- CUT HERE --------------------------------

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

# Form implementation generated from reading ui file 'a.ui'
#
# Created: Fri May 08 14:05:37 2009
#      by: PyQt4 UI code generator 4.4.4
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(800, 600)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.treeWidget = QtGui.QTreeWidget(self.centralwidget)
        self.treeWidget.setGeometry(QtCore.QRect(130, 90, 256, 192))
        self.treeWidget.setObjectName("treeWidget")
        item = QtGui.QTreeWidgetItem(self.treeWidget)

########################################################################
The following line seems to be unneeded and causes an error when calling
setupUi():

        self.centralwidget.setSortingEnabled(__sortingEnabled)

        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 22))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):

MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow",
"MainWindow", None, QtGui.QApplication.UnicodeUTF8))
        self.treeWidget.headerItem().setText(0,
QtGui.QApplication.translate("MainWindow", "1", None,
QtGui.QApplication.UnicodeUTF8))
        __sortingEnabled = self.treeWidget.isSortingEnabled()
        self.treeWidget.setSortingEnabled(False)
        self.treeWidget.topLevelItem(0).setText(0,
QtGui.QApplication.translate("MainWindow", "Neues Element", None,
QtGui.QApplication.UnicodeUTF8))
        self.treeWidget.setSortingEnabled(__sortingEnabled)

--------------------------- CUT HERE --------------------------------

The error message is (here called from interactive console):


--------------------------- CUT HERE --------------------------------
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "a.py", line 22, in setupUi
    self.centralwidget.setSortingEnabled(__sortingEnabled)
AttributeError: setSortingEnabled
--------------------------- CUT HERE --------------------------------


Thanks in advance for looking into this.

Kind regards,
Arkadiusz Wahlig




More information about the PyQt mailing list