[Qt-interest] QTableView/QSqlTableModel: how to set order of columns in header ?

Sean Harmer sean.harmer at maps-technology.com
Fri May 15 22:46:39 CEST 2009


Stephen Collyer wrote:
> I am populating a QTableView from a QSqlTableModel. I am selecting
> a set of columns in the model, which we can call A, B, C, D.
>
> I want to have the columns displayed by the view in the order
> C, B, A, D from left to right. Can anyone suggest how I can do this ?
> I can't see anything in the maze of table/view classes that allow this
> to be done.
I an think of a couple of options:

(i) Use a QSqlQueryModel instead and query for your columsn in the 
required order/
(ii) Use an intermediate QSortFilterProxyModel to re-arrange your 
columns as desired.

HTH,

Sean




More information about the Qt-interest-old mailing list