Reputation: 1993
I have a neat Model based off QAbstractItemModel. This has a simple hierarchical tree structure which works perfectly for QTreeView. However, I want the QTableView/QListView to access and display only the leaf nodes( ALL leaf nodes ). What is the best way to do this? I don't want to rebuild the model( because it will be expensive ) and I do not want to have two models( same reason ).
Upvotes: 3
Views: 1760
Reputation: 53173
I think you will need these steps to achieve this:
So, you could just wrap this flattening model inside a QSortFilterProxyModel
.
QFlattenProxyModel
is work in progress to be included in Qt:
https://bugreports.qt.io/browse/QTBUG-117716
Upvotes: 0
Reputation: 4390
You could create a proxy model. A class that sits between the View and the Model and filters out all of the non-leaf nodes and then just forwards the function calls to the original model for the leaves.
Upvotes: 1