user671253
user671253

Reputation:

How to Filter a QAbstractTableModel model

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.

Upvotes: 0

Views: 2904

Answers (1)

cmannett85
cmannett85

Reputation: 22346

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.

Upvotes: 1

Related Questions