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.

Georg Schölly
  • 124,188
  • 49
  • 220
  • 267

2 Answers2

2

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
  • 3,677
  • 1
  • 27
  • 28
  • 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 May 28 '09 at 15:58
0

What happens with?

table = QTableWidget();
table.setColumnCount(3);
table.horizontalHeader().restoreState(settings.value("savedState"));
Pavels
  • 1,256
  • 1
  • 12
  • 19