<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hey Dan,<br>
<br>
Thanks, I will check out the classes you suggest. I have also had some
success with QSqlQueryModel instead of QSqlTableModel, by setting the
query in such a way as to return the values in the order I want them.<br>
<br>
Cheers,<br>
Tom<br>
<br>
Dan Kripac wrote:
<blockquote
cite="mid:AANLkTi=03dGpGYUjX+3U0w--gdFdxV2jU=ztVOr64aVx@mail.gmail.com"
type="cite">Hey Tom (hey - don't I work with you? ;-),
<div><br>
</div>
<div>Have you tried looking at making a <a moz-do-not-send="true"
href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qabstractproxymodel.html">QAbstractProxyModel</a> subclass
or even better a <a moz-do-not-send="true"
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 moz-do-not-send="true" href="mailto:tmp@dneg.com">tmp@dneg.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; 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 moz-do-not-send="true"
href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a><br>
<a moz-do-not-send="true"
href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt"
target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>