0

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Do you have any example on how i can use it...I was reading on QAbstractProxyModel and QSortFilterProxyModel ...any sample code...thankz
Not personally, I've only used it in a circumstance too simple to be reflective of what you need. But there's bound to be some somewhere on the web, what your asking isn't unreasonable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.