Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QTableView sorting and headers issue



  • I have subclassed QSortFilterProxyModel and reimplemented lessThan in order to sort by multiple columns.

    I have a problem in that in order for it to work I have to make call setSortingEnabled() on my QTableView. This makes clicking my headers sort by that column and disables selecting columns.

    Is there a way to make sorting work and have selectable headers?



  • The solution was to explicitly call sort after the call to invalidate with setSortingEnabled set to false. Both invalidate and sort were necessary