[Interest] Sorting numbers in QSortFilterProxyModel with QSqlTableModel source

Michael Vlach vlach.michael at gmail.com
Fri Oct 31 07:21:45 CET 2014


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 as a source model for the proxy then this always
evaluates to QString (the default) and thus sorting 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 explicitly? I am pretty sure that the problem is
with QSqlTableModel disregarding the types of fields in the database (or
QSqlQuery/QSqlDatabase behind it).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20141031/5b00909e/attachment.html>


More information about the Interest mailing list