Hey Tom (hey - don't I work with you? ;-),<div><br></div><div>Have you tried looking at making a <a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qabstractproxymodel.html">QAbstractProxyModel</a> subclass or even better a <a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qsortfilterproxymodel.html">QSortFilterProxyModel</a> class and putting it between your QSqlTableModel and your QTableView?</div>
<meta charset="utf-8"><div><br></div><div>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?</div><div><br></div>
<div>Cheers</div><div>Dan</div><div><br><br><div class="gmail_quote">On 2 September 2010 17:08, Tom Proctor <span dir="ltr"><<a href="mailto:tmp@dneg.com">tmp@dneg.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
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.<br>
<br>
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.<br>
<br>
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.<br>
<br>
Any ideas?<br>
<br>
Thank you,<br>
Tom<br>
_______________________________________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
</blockquote></div><br></div>