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

QFileSystemModel does not work with QML DelegateModel

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 6.8.2, 6.9.0 FF
    • 6.8
    • GUI: Other
    • None
    • 7dda22389 (dev), 5e0173452 (6.8), bf714c246 (dev), 4059ea60e (6.8)

    Description

      In the documentation for DelegateModel::rootIndex(https://doc.qt.io/qt-6/qml-qtqml-models-delegatemodel.html#rootIndex-prop ) there is an example using the DelegateModel in combination with the QFileSystemModel. This example does not work correctly. One cannot navigate the folder structure as the rootIndex is constantly being reset.

      Using a debugger I found that the rootIndex is reset by the DelegateModel in QQmlDelegateModel::handleModelReset. handleModelReset is called by QQmlDelegateModel::_q_layoutChanged if the LayoutChangeHint is not set. As QFileSystemModel::sort emits layoutChanged with default parameters this is not the case.

      My proposed fix would be to change QFileSystemModel::sort to emit layoutChanged with VerticalSortHint.

      Thanks in advance 

      Attachments

        Issue Links

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

          Activity

            People

              srutledg Shawn Rutledge
              oweissbarth Oliver Weißbarth
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes