Sort and Filter a QSqlQueryModel
Jump to navigation
Jump to search
Sort and Filter a QSqlQueryModel
QSortFilterSqlQueryModel is a QSqlQueryModel subclass that allows server-side sorting and filtering.
Feel free to download and test it.
Example usage
You can connect a QLineEdit’s textChanged signal to the filter slot:
filter is the same as setFilter, but it also call select();
Sorting is done automatically by the view, using the sort implementation. You can also use setSort to set a sort order before select()ing.
Warnings
- It has only been tested in Windows using MySQL
- It won’t work using setQuery(QSqlQuery). I didn’t needed it so you have to reimplement it yourself.
- Works for me. May not work for you. :P