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

QQuickTreeModelAdaptor1 :: lastChildIndex does not consider rootIndex

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • Not Evaluated
    • None
    • 5.15.19, 5.15
    • Quick: Controls 1
    • None
    • All

    Description

      一个 TreeView 的问题(5.15),折叠一个目录时,没有收起子节点的 View。

      排查下来问题出在 QQuickTreeModelAdaptor1::lastChildIndex 中。这个方法没有考虑 rootIndex,到了 root 还没有退出 while 循环。

       

      In English:

       
      A TreeView issue (5.15), when collapsing a directory, the sub-node View is not collected.
       
      The problem lies in QQuickTreeModelAdaptor1 :: lastChildIndex. This method does not consider rootIndex, and it has not exited the while loop when it reaches root.

       
      How to reproduce:
       

      • Use FileSystem TreeView demo from Qt
      • Create a directory struct:

        test
           - 1
              -  2
                  - 3
                     - 4
                       - README.txt
           - 5

         

      • fsm->setRootPath("D:/test");
      • engine.rootContext()>setContextProperty("rootPathIndex", fsm>index(fsm->rootPath() + "/1/2"));
      • start program
      • expand directory 3 and 4
      • fold directory 3 and it does't fold
      • expand directory 3 again, it will create duplicate nodes (as the second picture)

       

      See test.zip and filesystembrowser.zip

       

      Attachments

        1. filesystembrowser.zip
          7 kB
          William Wei
        2. image-2025-05-09-12-02-37-272.png
          14 kB
          William Wei
        3. image-2025-05-09-12-05-44-434.png
          16 kB
          William Wei
        4. test.zip
          0.9 kB
          William Wei
        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
            william.wei William Wei
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes