[PyKDE] Qt - PyQt problem in populate tables

David Boddie david at boddie.org.uk
Thu Nov 9 01:08:35 GMT 2006


On Wednesday 08 November 2006 17:11:20 +0000 (UTC), Carlos Eduardo wrote:

> I have an application written with Qt 4.1.4 and PyQt 4.0.1.
>
> I have some forms with tables that i populate using a code like this:

[...]

> for prodItem in prodItems:
>     row = self.prodTable.rowCount()
>     self.prodTable.insertRow(row)
>  
>     for data, col in zip(itemData,
>                     range(self.prodTable.columnCount())):
>         self.prodTable.setItem(row, col,
>                                QtGui.QTableWidgetItem(str(data)))

[...]

> When the Qt4.2 came I started my tests with it and the latest PyQt and SIP
> snapshots, I found that if my table has the <property
> name="sortingEnabled"> in the table, my function does not populate the
> table correctly leaving the rows blank filling only the last one. This
> happens in the latest 4.2.1 QT and 4.1 PyQt.

Yes, it's a behavioural change in Qt 4.2 (see task 132119):

http://www.trolltech.com/developer/task-tracker/index_html?method=entry&id=132119

The table is sorted dynamically as data is entered, meaning that each row can
be moved when you enter data in the column that determines the sort order.
You can't find out where it moved to.

> I dont know if this could be a PyQt problem or a Qt bug. If its a QT one,
> how can I contact Trolltech because I only write in Python and dont code in
> C.

You can still report bugs if you find them using Python (or some other
language) but you may be asked to provide a simple C++ test case. It may
help your case if you have a Commercial Qt license (in the sense that it's
always good to keep customers happy), but it won't affect how the bug is
filed.

In this case, I believe the workaround is to disable sorting before
entering the data into the table and to re-enable it afterwards.

David




More information about the PyQt mailing list