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

currentIndex In TreeView is not update on removeRow in the model

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.15.0 Beta2
    • 5.6.0
    • Quick: Controls 1
    • None
    • Qt 5.6.0 QML Windows 7 mingw
    • b26bfb18616e2a4baf33f9f1a2c147e3f5512de6 (qt/qtquickcontrols/5.14)

    Description

      TreeView.qml line 49
      readonly property var currentIndex: modelAdaptor.mapRowToModelIndex(__currentRow)
      

      In a TreeView, when the selected row was remove in the model, the __currentRow does not changes, but the __currentRowItem change. So the currentIndex need to be updated when the __currentRowItem changes else currentIndex contains a pointer to a deleted entry.

      my Patch :

      TreeView.qml line 49
      readonly property var currentIndex: {__currentRowItem; modelAdaptor.mapRowToModelIndex(__currentRow);}
      

      This path is not the final solution, because when you click on an item of the TreeView currentIndexChanged is emitted two times with the same currentIndex. So if you make something onCurrentIndexChanged, this things is made two times.

      May be the good solution is to emit q->currentIndexChanged() in qquickitemview.cpp in updateCurrent(int modelIndex) when currentItem changed even if curentIndex is the same.

      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
            zapco Olivier Percheron
            Votes:
            13 Vote for this issue
            Watchers:
            16 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes