Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
5.13.0
-
None
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?