[Interest] Sorting numbers in QSortFilterProxyModel with QSqlTableModel source
Bo Thorsen
bo at vikingsoft.eu
Mon Nov 3 09:14:45 CET 2014
Den 01-11-2014 08:26, resurrection at centrum.cz skrev:
>
> By default QSortFilterProxyModel can sort few different types using
> QVariant::type to see what is in it to do the correct sort. However
> when the QSqlTableModel is used then this always evaluates to QString
> (the default) and thus sorts numbers as strings. I wrote my own
> subclass of the filter model to force sorting by number but I wonder
> if there is a way to tell the QSortFilterProxyModel by what type it
> should sort? I know that the problem is obviously with QSqlTableModel
> disregarding the types of fields in the database but that is hardly
> something that could be influenced that easily.
>
I always find myself writing the full sorting myself. The default
implementation is fine to get something up and running quickly, but at
some point I implement my own.
Looks like you're on the same path.
Bo.
--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
More information about the Interest
mailing list