views:

137

answers:

2

My code looks somehow like the following:

table = QTableWidget()
table.horizontalHeader().restoreState(settings.value("savedState"))
table.setColumnCount(3)

settings.setValue("savedState", table.horizontalHeader().saveState())

If I run it the first time it there are only 3 column headers. The second time there are 6 and the third 9... The strange thing is table.columnCount() is always 3. If i remove table.setColumnCount(3) there are no columns at all.

Why is this happening and is it a bug or intentional?

UPDATE

Adding table.clearContents() before table.setColumnCount(3) made it work. I still think it's a bug.

A: 

What happens with?

table = QTableWidget();
table.setColumnCount(3);
table.horizontalHeader().restoreState(settings.value("savedState"));
Pavels
+1  A: 

Which platform and what Qt version is this? http://chaos.troll.no/~hhartz/tablecolumns.tar seems to work fine using latest Qt 4.5

Henrik Hartz
PyQt 4.4.4, on xubuntu 9.04
Georg
In that case it appears that this problem is fixed in a later version than the one you're using. You might want to try the PyQt 4.5 snapshot to see if this is fixed.
Henrik Hartz