5

I have a QTableWidget that is used to display lots of data, basically derived from a function f(a,b). All a values go into the horizontal header, all b values into the vertical header and all f(a,b) into the corresponding cell.

The columns should be sortable. When a user clicks a column, all values in that column are sorted and all other columns are also "synchronized", since whole rows are sorted (using the clicked column as a sort criterium).

This works. Except for the "header column", the vertical header. The vertical header does not change, it does not synchronize with the reorganized rows. Is this the intended behaviour? Is it a bug in my code? How do I make the vertical header sort, too? Or do I need to add my b's to an ordinary column?

edit: I solved it now by making the header column an ordinary column. Though, I would still be interested in why the vertical header does not sort with the other columns.

Sebastian Negraszus
  • 11,915
  • 7
  • 43
  • 70
  • How exactly do you sort your data? Perhaps i am wrong but it seems that QTreeWidget doesn't have any sorting functionality, so i assume that you simply sort it yourself by exchanging rows/columns - if it is so, then you need to call setHorizontalHeaderItem and setVerticalHeaderItem when filling the table, and then exchange those elements too. – j_kubik Oct 01 '11 at 01:12

1 Answers1

2

Try to use QTableView instead of QTableWidget.
And use QAbstractTableModel for computing f(a,b)

k06a
  • 17,755
  • 10
  • 70
  • 110