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

Calling sortByColumn() on a view with proxy model set resets header section settings

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • None
    • 5.10.1
    • Widgets: Itemviews
    • None
    • Windows 10, Visual Studio 2017

    Description

      I have a table view and a proxy model for sorting. Calling `sortByColumn()` on the view changes section resize mode on the header and section sizes.

      This is a regression found when porting from Qt 5.6.2, where it worked correctly (the mode and section sizes didn't change).

      Example code:

      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          QTableView tw;
          tw.show();
      
          QStandardItemModel md;
          md.setColumnCount(1);
      
          QSortFilterProxyModel proxy;
          proxy.setSourceModel(&md);
          tw.setModel(&proxy);
      
          tw.horizontalHeader()->setSectionResizeMode(0, QHeaderView::Fixed);
      
          qDebug() << tw.horizontalHeader()->sectionResizeMode(0);
          tw.sortByColumn(0);
          qDebug() << tw.horizontalHeader()->sectionResizeMode(0);
      
          return a.exec();
      }
      

      Debug output is:

      QHeaderView::ResizeMode(Fixed)
      QHeaderView::ResizeMode(Interactive)
      

      Attachments

        Issue Links

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

          Activity

            People

              tmartsum Thorbjørn Lund Martsum
              chrisaverage Krzysztof Kawa
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes