[Qt-interest] QSortFilterProxyModel disable sorting

Andras Toth parrotfortytwo at gmail.com
Fri Oct 15 14:53:47 CEST 2010


On Friday 15 October 2010 07:52:59 am Andre Somers wrote:
>   Op 14-10-2010 22:11, Andras Toth schreef:
> > Hello, is there any way to disable sorting in QSortFilterProxyModel? (in
> > order to use it just for filtering, but not sorting). According to the
> > documentation there is a setSortingEnabled method for the view classes,
> > but not for the models.
> 

Hello,

Thanks to everybody for the suggestions, the empty sort method is a right 
solution. However I must admit, I wrongly thought that sorting happens by 
default* on QSortFilterProxyModel (like filtering). Now, after some 
experimenting, I found out that it does not happen unless you explicitly call 
the sort() method.

Regards,

András

* Until now I did not really care about the values themselves, I was just 
doing some benchmarking (I had only implemented filtering) and I found that 
the update time of the filter was increasing exponentially in relation to the 
count of items. I thought this was due to the supposed automatic sorting, 
since filtering should increase only linearly, that's why I wanted to disable 
it.
I found, however, that the bottleneck was in the implementation of data() and 
setData() methods of my model, so sorting (which does not happen at all) is 
not culpable.





More information about the Qt-interest-old mailing list