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

QTableView model that allows appending and sorting?



  • I have been using QStandardItemModel with a QTableView, this enables me to append content to the table. Now I would like to implement sortable columns so I'm looking at QSortFilterProxyModel however it isn't quite the same in that it doesn't appear to have an append function.

    Is there another way or another model that supports both that I should be using?



  • I think the solution is to call setSourceModel and pass it an instance of QStandardItemModel, I also had to call setSortingEnabled(true);



  • I think the solution is to call setSourceModel and pass it an instance of QStandardItemModel, I also had to call setSortingEnabled(true);


  • Lifetime Qt Champion

    Hi,

    A proxy model is put between a view and another model. It does not provide any API to modify the source model as it is not its role.

    You still interact with your original model for everything that is related to adding removing rows, columns, etc.


Log in to reply