Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-137580

QML TreeView: allow expanded state to be set on hidden rows

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 6.8.3
    • None
    • All

    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.

       

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            bob64 Ian Boyd
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes