PDA

View Full Version : Restore QTreeView expanding



zack
25th November 2009, 18:35
I want to restore the expanding of a TreeView.

What would be the easiest approach?
I'm thinking of something like, iterating through all QModelIndexes of the first column and storing the expanding flag of this Modelindex.

Then I refill the tree and set the expanding settings to the same items, but only with the knowledge of the row and column number...

what do you think?

wysota
25th November 2009, 18:54
Yes, it should work. Provided you get the same tree as last time. Another approach would be to assign an ID to every node in the tree and store the list of IDs that are expanded. Then regardless of the shape of the tree when you restore the state, if IDs are kept, proper items will be expanded.