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

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.9.2
    • Core: Item Models
    • None
    • Red Hat Enterprise Linux Server release 7.5 (Maipo)
      GCC 4.8.5
      Qt 5.9.2 (from package manager)
    • 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

            dfaure_kdab David Faure
            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