سؤال

I represent same data in QTreeView with QStandardItemModel. Data is table - I have rows and columns, I get it from DB with QSqlQuery. How can I filter rows based on some column value? For example I have third column some integer value, and by clicking some button I want to show only rows with this number > 10. I can perform another QSqlQuery.exec, but it is possible to do so with QTreeView or QStandardItemModel?

هل كانت مفيدة؟

المحلول

To filter out data you may use QSortFilterProxyModel. By overriding other methods you can format data in underlying model, so there is no need to fill QStandardItemModel on your own and use QSqlTable model as a source instead.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top