[Qt4-preview-feedback] Suggestion: move QSqlTableModel::sort function to class QSqlQueryModel

Harald Fernengel harald at trolltech.com
Wed Feb 4 10:47:27 CET 2009


Hi,

On Wednesday 04 February 2009 02:28:38 yanyaqin2004 wrote:
> Hi,
>   It is usefule if class QSqlQueryModel has the virtual function sort.
> What's you opinion ?

In QSqlQueryModel, the developer defines the SQL query. The model doesn't touch 
it.

In QSqlTableModel, the class creates the SQL query, so it can also set the 
ORDER BY clause.

Sorting in QSqlQueryModel must be done by the developer himself by setting the 
appropriate ORDER BY clause.

If you don't want to sort server-side, but do it client-side, I suggest to use 
a QSortFilterProxyModel.

Hope this helps,
Harald



More information about the Qt4-feedback mailing list