[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: [PyQt] QSqlRelationalTableModel - sort on multiple columns?
From: Joe Planisky <jplan () jeffnet ! org>
Date: 2010-03-28 19:10:14
Message-ID: AF836465-5488-4406-8B86-562AE3D6F708 () jeffnet ! org
[Download RAW message or body]
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 PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic