Question

I have created a QAbstractTableModel model called tableModel and QAbstractListModel model called listModel andi have set these model to respective views (QTableView and QListView).I want to filter the tableModel based on the listModel.That mean when someone clicks on a listitem and the tableview should be filtered based on the list item.These models are working perfectly.Please help on how i can do the filtering.

In QSqlModel we can use setFilter member with sql relationship to do that.

Was it helpful?

Solution

You need to use QAbstractProxyModel to act as an intermediary between the tableview and the table model. So when an item is clicked on in the listmodel, notify the table proxy to filter all out the unnecessary items from tablemodel for when the table view queries them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top