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

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

XMLWordPrintable

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

      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)
      

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

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes