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

QSortFilterProxyModel error or not?

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 5.13.0
    • Core: Item Models
    • None
    • All

    Description

      _stringListModel = new QStringListModel(parent);
      _sortFilterProxyModel->setDynamicSortFilter(true);
      _sortFilterProxyModel->setSortRole(Qt::DisplayRole);
      _sortFilterProxyModel->setSourceModel(_stringListModel);
      
      ui->tableView->setModel(_sortFilterProxyModel);
      _stringListModel->setStringList({"34", "5", "2", "65", "100", "32", "37", "23", "35", "108", "245", "210"});
      

      There is no automatic sorting.

      If you continue to invoke the command:

      _sortFilterProxyModel->sort(0);
      

      The further sorting is performed.

      Looking through the code I realized that it is because the command sets (proxy_sort_column):

      void QSortFilterProxyModel::sort(int column, Qt::SortOrder order)
      { 
        Q_D(QSortFilterProxyModel);
        if (d->dynamic_sortfilter && d->proxy_sort_column == column && d->sort_order == order)
          return;
        d->sort_order = order;
        d->proxy_sort_column = column;
        d->update_source_sort_column();
        d->sort();
      }
      

      And also (proxy_sort_column) is set when:

      _q_sourceColumnsInserted, _q_sourceColumnsRemoved

      which in (QStringListModel) are missing.

      Is this a normal situation or a bug?

      Attachments

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

        Activity

          People

            dfaure_kdab David Faure
            zivarg Evgeny Belousov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes