Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt Table and Tree View with the same model

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 ).

like image 387
jetru Avatar asked Feb 12 '26 22:02

jetru


1 Answers

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.

like image 193
Gianni Avatar answered Feb 15 '26 12:02

Gianni



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!