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

QSortFilterProxyModel + QML ListView inefficient move handling

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 6.7.2
    • Core: Item Models
    • None

    Description

      When using a QSortFilterProxyModel to proxy some source model it will convert all move operations on the source model into layoutChange operations internally:

      https://github.com/qt/qtbase/blob/4aad091c5ead4062d4478f3c4a1d5edd74d83846/src/corelib/itemmodels/qsortfilterproxymodel.cpp#L1745-1759

      When using a QML ListView with a QSortFilterProxyModel model it will re-create every visible delegate every time a move operation is detected because of this layoutChange logic. This can cause significant jank if the delegates are expensive to instantiate.

      I've attached a simple test project using a QStandardItemModel and a QSortFilterProxyModel exposed to QML to demonstrate this issue.

      It includes two buttons, one will move the rows the other will move the rows but by removing and then inserting to avoid any rowsAboutToBeMoved signals. Notice how the move button causes all the visible ListView delegates to be recreated whereas removing and inserting only re-creates the newly inserted row.

      One solution here might be to handle move operations as remove / insert operations in QSortFilterProxyModel as that appears to work better (at least with QMLs ListView). I would be curious to hear if there would be any downsides to that approach. Obviously properly handling move operations would be the ideal solution if possible.

       

      Attachments

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

        Activity

          People

            dfaure_kdab David Faure
            haiku Ollie Dawes
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes