Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QSortFilterProxyModel: dynamicSortFilter vs. calling sort()
Asperamanca last edited by
As far as I understand, you can either have the QSortFilterProxyModel sort dynamically using dynamicSortFilter, or manually call the sort() method.
First, am I missing a third way?
Second, can someone please explain what the following sentence from the dynamicSortFilter documentation means:
bq. Note that you should not update the source model through the proxy model when dynamicSortFilter is true.
Third, given the following scenario, which way offers better performance, dynamicSortFilter or sort()?
The model has ~600 items. The number and identity of the items do not change, but some of their values can change (they do however have a key that remains constant).
Every second, ~30 items change their value. This can affect sorting. (Let's assume for now we do not filter). The sort order must always be correct, so re-sorting must occur every second.
The value changes can affect any item in the model, we cannot create ranges of changed data.
On the one hand, we have the dynamicSortFilter, which has to process 30 single changes, but only re-sorts the items that actually changed into the model (as far as I understood the code).
On the other hand, we have the sort() method, which affects the whole model (again, as I understood the code), but has to be called only once.
Before you ask why this is a performance problem at all: It's running on slow embedded hardware. However, I might want to scale the application to run on a PC, which larger models and more changes. Then, I assume I would run into the same question anyway.