I have a Qt QTreeWidget
and I am trying to save the state of which header items were expanded so that when I refresh my tree with new information it can re expand the items that were previously expanded.
Each time an itemExpanded
or itemCollapsed
signal
is emitted I catch it in a slot
and save to a member boolean
for that particular item to represent whether expanded is now true
or false
. This is my memory.
When refreshing the tree I clear the tree completely using
clear();
Next I collapse all the headers using
collapseAll();
Now I want to restore which items were expanded and set them to expanded using each boolean
I have that represents whether the item was previously expanded or collapsed using
expandItem();
I'm not particularly sure how to get the index of the item from my boolean
alone.
I would of thought that
indexOfTopLevelItem(0);
Would give me the index of my toplevelitem
at position 0 and then using my boolean
associated with position 0 I could then decide whether to expand the item?
This also doesn't solve my problem of wanting to do it to each 'boolean' I have representing each item in the tree.
Thanks in advance.