View Full Version : QTableWidget vs QTableView and setSortRole

30th June 2011, 20:25
I need to sort a table by different values that are displayed in the cells.

The QTableView model has wonderful option to do it.


But I do use QTableWidget and don't want to switch to TableView.

What I can use to get it working in TableWidget instead ??


1st July 2011, 13:03
setSortRole() is a method of QStandardItemModel, not of any of the table view classes.
ALso, since QTableWidget is derived from QTableView, QTableWidget IS a QTableView, and you wouldn't need to switch between classes.