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

Stephen Collyer scollyer at netspinner.co.uk
Sat May 16 15:55:25 CEST 2009


2009/5/15 Sean Harmer <sean.harmer at maps-technology.com>

> 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/


Thanks. This looks like the most appropriate approach for me. I note
that you can use a preconstructed QSqlQuery to populate the model,
which in my case works nicely, as I have a set of canned queries in
another class that I may as well reuse.

-- 
Stephen Collyer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090516/eaeeeeb4/attachment.html 


More information about the Qt-interest-old mailing list