PDA

View Full Version : Problem QSortFilterProxyModel



estanisgeyer
13th June 2009, 15:46
Hi,

I have a QSqlQueryModel I do a SELECT on a table with more than 1000 records and apply a QTableView.
When using a QSortFilterProxyModel to sort by fields, only the records that are currently in QTableView are ordered (more or less about 300).
Example, if I have a list of customers from A to Z, by clicking on the "name" to sort in descending order, they order from F to A. It's bug in QT?
Will require reimplementation QSqlQueryModel::sort( ) and back using the SQL ORDER BY clause?

Thank,

Marcelo E. Geyer

wysota
15th June 2009, 18:30
No, it's not a bug. It's just Qt doesn't download all the rows from the database for efficiency reasons. You need to call
while(model->canFetchMore()) model->fetchMore(); to make sure all the rows are retrieved and cached.

estanisgeyer
15th June 2009, 19:37
So, imagine that. Not to lose this efficiency, the method you suggest reimplemented sort and using SQL ORDER BY? Take into consideration that access can occur through the Internet.

I have other thread open, if you could read I would be very grateful:
http://www.qtcentre.org/forum/f-qt-programming-2/t-sql-transactions-with-qsqlquerymodelqtableview-21650.html

Thanks for reply.

Marcelo E. Geyer

wysota
15th June 2009, 19:51
So, imagine that. Not to lose this efficiency, the method you suggest reimplemented sort and using SQL ORDER BY? Take into consideration that access can occur through the Internet.

I'm not sure what you mean...