Reputation: 6193
I have a table which makes use of a QSortFilterProxyModel. It is also responsible for sorting the elements depending on a specific column clicked by the user. Now I found this is incredibly slow when the table shows some 10000 elements, it can take several seconds. The whole thing is not reproducible, depending on how the columns are already presorted it can take longer - but does not do in all cases.
The sort-function within QSortFilterProxyModel is some really weird stuff with maps where parts of it are sorted and shuffled and whatever … I did not understand exactly what is going on there.
So my idea is to create an own model which inherits from QSortFilterProxyModel but implements own sorting functionality - like QSortFilterProxyModel but in a more efficient way (the STL-sort-stuff should do the job as it is quite fast with my data).
So my question: how can I do that? What do I have to implement in order to have an own sorting function? Or is there a better way to speed-up the standard QSortFilterProxyModel?
Thanks!
Upvotes: 0
Views: 366
Reputation: 6329
What's wrong with reimplementing virtual QSortFilterProxyModel::sort()
?
Note that the Qt implementation already uses STL (std::stable_sort()
) to do the actual sorting.
The problem with the sorting is that you need to get somehow to the source index of the sorted items. This makes things a little bit more complicated. If you do not have any cascaded proxy models, the mappings are trivial and will not cost too much time.
Summing up: I don't think, you'll be faster than the Qt code.
Upvotes: 1