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

Saved sort column index on QSortFilterProxyModel is lost when inserting or removing columns and the first row in the model is filtered

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 5.9.2
    • Fix Version/s: None
    • Component/s: Core: Item Models
    • Labels:
      None
    • Environment:
      Red Hat Enterprise Linux Server release 7.5 (Maipo)
      GCC 4.8.5
      Qt 5.9.2 (from package manager)
    • Platform/s:
      All

      Description

      Steps to reproduce the bug:

      • Connect a model to a QSortFilterProxyModel; proxy.setSourceModel(model)
      • Define your QSortFilterProxyModel such as it always filter the first row from the model (important)
      • Append data in your model
      • Sort the data with a column; proxy.sort(1) for example
      • Read proxy.sortColumn() it returns 1
      • Insert or remove a column on the model; at the 5th position for example
      • Read proxy.sortColumn() it returns -1 (BUG)

      Expected:

      • Keep the sort column index

       

      When analysing Qt sources I think the problem comes from this code in the file src/corelib/itemmodels/qsortfilterproxymodel.cpp:

      proxy_sort_column = q->mapFromSource(model->index(0,source_sort_column, source_parent)).column();

      This line is executed when inserting or removing columns, it tries to translate the saved sort column index from the model to the proxy using the first row in the model. But it cannot map it to the proxy as the first row is filtered in my case.

      Also, the code related to this line seems exactly the same in 5.15. This bug may affects other versions of Qt.

        Attachments

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

          Activity

            People

            Assignee:
            dfaure_kdab David Faure
            Reporter:
            bbalp Barnabé BALP
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes