Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
6.8.3
-
None
Description
The Qt 6 tree view API only supports setting the expanded/collapsed state of visible rows. In Qt 5 it was possible to do this based on the underlying model index and it was therefore possible to set the expansion state of a node that is not yet shown.
The previous behaviour was useful as I have some complex requirements regarding which nodes should default to being expanded when they are first added to the tree. Sometimes these are child nodes of parents that are initially collapsed. The idea is that if the user expands the parent, the children should be shown in their default expanded state.
This was relatively straightforward in Qt 5 as I could listen for newly added sub-trees, and apply the logic to the whole sub-tree in one go. Any subsequent changes in expansion status of that sub-tree will only be from user interactions and be purely managed by the TreeView.
In Qt 6 I will have to maintain much more state in order to use the new API so that I can correctly expand certain nodes the first time they become visible.
The TreeView itself must be aware of the expansion state of hidden nodes because the expansion state of a child branch is preserved if a parent is collapsed and re-expanded so it would be useful if a model index-based API to this could be exposed.