I created a custom model that stores some data as a tree. When I set the model of the QTreeView with my model, it displays correctly. When I set the model of the QTableView with my model only the root node is displayed, as expected.
What would be the best way to have the QTableView display the leaf nodes of the tree, depending on what node is selected? I don't want to create a new model for the QTableView, because I want single clicks on items in the QTreeView to have the same functionality as double clicking on items in the QTableView.
Example: here is a model stored as a tree. A is the root, B and E are children of A, C and D are children of B, F and G are children of E.
A
----B
--------C
--------D
----E
--------F
--------G
If A is selected in the QTreeView, then C, D, F and G would be displayed in the QTableView.
if B is selected in the QTreeView, then C and D are displayed in the QTableView.
if E is selected in the QTreeView, then F and G are displayed in the QTableView.
I'm trying to avoid creating a custom view for the table. Doing that seems very complicated. I've been looking at using the QSortFilterProxyModel, but not sure if this is going to do what I need.
Again, I want the selection of the item in the QTreeView to initiate the same action as the selection of the item in the QTableView. My custom model has custom items that store information about devices on a network. So I need the QTreeView and QTableView to be connected.
Any thoughts on how to do this?
Thanks,
-David
Bookmarks