I have created a QTable view and connected it to a QSqlTableModel and i am displaying the resulted Query retrived from the database.In QTable view i have enabled sortEnabled option. All the expected results are printing but if i click the sort indicator
the whole data in the table is getting emptyed. Can any one suggest me how to overcome this issue
This is the snap shot of the results table.

This is the snap shot of the results table after pressing sort indicator.

Can any one suggest me how to overcome this issue
To figure out why QTableView’s setSortingEnabled method wasn’t working is, It turns out the sort method in QAbstractItemModel is not implemented. So you have to implement it yourself.
One solution would be creating a QAbstract view. below is a code snippet.
I’m not sure if this is the best way to implement the sort method, but I couldn’t find anything else out there, and this seems to work for me.