Re: Filtering QSqlQueryModel
Quote:
Originally Posted by
mourad
Hello everyone, I want to filter QSqlQueryModel. I've used QSortFilterProxyModel but I have many fields to filter on. All depends on the user criteria.
I have a look on the Qt documentation but I've not found anything that helps me.
Can anyone help me to resolve this problem.
Many thanks in advance.
Best Regards.
Hi,
one of the possibility is to use more than one QSortFilterProxyModel to filter you data. This approach can be applied if the filter criteria is like "ColumnA = 'ValueA' AND ColumnB = 'ValueB' ....).
If the filtering criteria is more complex, you can make a subclass of QSortFitlerProxyModel and reimplement the filterAcceptRow method in order to implement your specific filter criteria.
Bye.
Alessandro
Re: Filtering QSqlQueryModel
Quote:
Originally Posted by
mourad
Hello everyone, I want to filter QSqlQueryModel.
:confused: How that, is the WHERE, GROUP BY clauses of your MySQL statement not enough? You can set new queries on the model, if your user criterias change. That would be the easiest approach.
Re: Filtering QSqlQueryModel
sql can do everything !
you have to just to know what to do + write the good query for that :)
Re: Filtering QSqlQueryModel
Building an SQL Where clause does work but if you go changing the filter query on a QSQlTableModel then you have to run select(), which invalidate your model, clears any associated selections, and reset the views losing the current position. Is there any way to avoid this?