Index for QTreeview from Root



  • Hi All,

    I am using a Qtreeview and I need to obtain the index based on the root node and not based on the parent

    Ex:
    RN
    --- Node 1
    --- Node 2
    --- Node 3
    --- --- Node 31
    --- --- Node 32
    --- Node 4
    --- Node 5
    --- --- Node 51
    --- --- Node 52

    Now when I click Node 31 or Node 32, I am getting it as 0/1 respectively. Instead can i get it as 3 & 4 when counted fromthe top Node (zero based index)

    Thanks,
    Pad



  • I have also thought about things like that, because I am also working with QTreeView's.

    But wouldn't your proposal lead to very strange behaviour? If a new item "Node 33" would be added as child of "Node 3", then all the indices of later nodes would be shifted - although they have nothing to do with the new node (just because they come later).

    Therefore I guess it is a good behaviour to use indices with respect to the parent items.

    Benjamin


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.