I would suggest not sorting data in model if you need only to display sorted data in QTableView.
There is another good solution: use QSortFilterProxyModel as a proxy between your model and QTableView. If you want to have some specific sorting then you only need to re-implement one virtual method
bool QSortFilterProxyModel::lessThan
But in most case its default implementation will be enough (see Qt help & examples on QSortFilterProxyModel)
Bookmarks