I have a question about multiple views for a particular model in PyQt.
Currently, I have a TreeView setup to display a model inheriting from StandardItemModel. There are three types of StandardItems in the model: Alpha
, Beta
, Gamma
. They are parented in the TreeView like so
+ Alpha
|
\------+ Beta
| |
| \------+ Gamma
| \------+ Gamma
| \------+ Gamma
\------+ Beta
| |
| \------+ Gamma
| \------+ Gamma
| \------+ Gamma
Currently, I only have the Alpha
and Beta
levels shown in a TreeView. What I'd like is for another TreeView to populate with Gamma
values depending on which Beta object I have selected in the first View.
I've figured that I can do this with setRootIndex()
, and just check if the selected item at the index in the first TreeView is an instance of the Gamma
item class. However, this only happens when I have selected a Beta
item in the first TreeView, otherwise, the second TreeView just shows everything.
How would I make sure that the second TreeView only populates when a Gamma
item in the first TreeView is selected?