Priority: Not Evaluated
Affects Version/s: 5.12.0, 5.13.0 Alpha 1
Fix Version/s: None
Component/s: Core: Item Models
currently I've searched for a method to turn on the sorting by column of QTreeWidget / QTableWidget with the behaviour to sort the items ONLY when the user clicks a column section.
For god's sake this is really a pain in the ass.
The method setSortingEnabled will immediately sort the first column, who ever was thinking this was a good idea, was out of his senses.
Currently you need to call setSectionsClickable(true) and catch sortIndicatorChanged where within you call sortByColumn on your own. This can't be combined with setSortIndicatorShown.
My suggestion for a much better and useful behaviour:
- setSortingEnabled will not immediately sort the first column. Sorting will only take place if the user forces it through a click in the header section or programmatically through sortByColumn.
- Sorting needs to have three states instead of two state: None, AscendingOrder, DescendingOrder
This have to be used to restore the original insert order, so that the user can turn of the Ascending/Descending order, where the sortIndicator will be hidden.
- It would be useful to define sections which shouldn't be sorted. Something like:
header()->disableSortingByColumn(int logicIndex, bool disabled)
These three changes will give the models/widgets a wide range of possibilities to configure them to your own needs. Such as only sorting through user interactions, disable sorting for columns/rows and restoring the original insert order through the user with indicators enabled.
I know that a proxy model is able to fulfill some of these requirements, but not everyone wants to write own models for some simple structured data / widgets.