I'm writing a simple database application with PyQt (Qt version 4.5.2, PyQt version 4.6). I'm using a QSqlRelationalTableModel to display records in a QTableView and everything is working as expected; the table view is populated with records, I can insert new records, sort on a column, etc.

However, now I want to sort on multiple columns. I.e. the column header I click on is the primary sort, and a different column is a secondary sort. Basically, I want to do the equivalent of "SELECT ... FROM table1 WHERE ... ORDER BY table1.email ASC, table1.date DESC;"

It seems that QSqlRelationalTableModel.sort(...) and .setSort(...) only support sorting on a single column. I've searched for an answer and the only thing I found was a suggestion to use different views in my database. When I come up this empty on a search, it's usually because there's some blindingly obvious way to do a thing that everyone else in the world but me knows about :-) What am I missing here?

The only thing I've done that had any success is replacing the model's query with a new one that explicitly specifies the "ORDER BY" clause. That worked, but seems to be a bit heavy handed.

How have others solved this problem?

--
Joe P

_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to