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

QFileSystemModel does not work with QML DelegateModel

XMLWordPrintable

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

      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 

        For Gerrit Dashboard: QTBUG-131487
        # Subject Branch Project Status CR V

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes