Hey Tom (hey - don't I work with you? ;-),

Have you tried looking at making a
QAbstractProxyModel<http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qabstractproxymodel.html>
subclass
or even better a
QSortFilterProxyModel<http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qsortfilterproxymodel.html>
class and
putting it between your QSqlTableModel and your QTableView?

You can override the MapFromSource and MapToSource methods and perhaps do
your column swapping in there? Or maybe you could do it all in the sort
filter model?

Cheers
Dan


On 2 September 2010 17:08, Tom Proctor <[email protected]> wrote:

> I would like to use a subclassed QSqlTableModel to fill a QTableView, but
> I'd like the order of the columns in the table to be different from the
> order of my fields in the database.
>
> I thought there must be some way to modify the query in .select() but I
> haven't gotten that to work.  Using setQuery only seems to prevent queries
> from returning values.
>
> I also tried simply changing horizontalHeader().moveSection() on the table,
> but this is ugly as it needs to be reset each time I filter or select again.
>
> Any ideas?
>
> Thank you,
> Tom
> _______________________________________________
> PyQt mailing list    [email protected]
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to