Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sort vertical headers of QTableWidget

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.

like image 692
Sebastian Negraszus Avatar asked Nov 05 '22 17:11

Sebastian Negraszus


1 Answers

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

like image 153
k06a Avatar answered Nov 15 '22 06:11

k06a