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