I am using QStandardItemModel in a QTreeView and trying to connect the selectionChanged signal of SelectionModel to track the user selection. I was able get the row/column of the selection. How do I get the level of the selected Item?
For example,
Animal
-FourLegged
--Dog
--Cat
-TwoLegged
--Human
Bird
-Flying
--Parrot
-NonFlying
--Chicken
Selecting Animal/Bird should return me 0.
Selecting FourLegged/TwoLegged/Flying/NonFlying should return me 1
Selecting Cat/Dog/Human/Parrot/Chicken should return me 2
Added after 24 minutes:
Currently I solved it by iteratively checking if the parent is NULL. Is there a better way ?
Bookmarks