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