4
votes

Is it possible to sort the headers of a QTableView? enter image description here

I'd like to sort the horizontal and vertical headers. QTableView only offers functionality to sort a column's contents. Is there a way to sort the view or do I have to sort the underlying datastructures?

1
Is it TableView or TableWidget? - ScarCode

1 Answers

2
votes

Afaik there is no pre-implemented way to do that.

One way would be to subclass QSortFilterProxyModel, sort the rows by whatever you use in order to fill the vertical header and then manually sort the columns using QHeaderView::moveSection().