Well, an SQL model + view is much better choice for showing data from database...
Well, an SQL model + view is much better choice for showing data from database...
J-P Nurmi
peterjb31 (27th March 2008)
Thanks, that makes a lot more sense that what I was trying to do. I am however still struggling to work out how to implement this. I read some documentation on QListView and the QSqlQueryModel here.
I don't understand how I create the model and then reference it. If anyone could either point me to an example of the code used (can't seem to find any for pyqt when I google) or alternatively post an example I would be extremely greatful.
I have created a QSqlModel using the following code in Python:
Qt Code:
self.model.setQuery("SELECT companyName FROM suppliers");To copy to clipboard, switch view to plain text mode
However when I try to run the code I get the following error:
Would anyone be able to advise as to what the error is. Have I declared the QueryModel properly, if not how do I?TypeError: first argument of unbound method QSqlQueryModel.setQuery() must be a QSqlQueryModel instance
Excuse me, I'm not a Python expert but shouldn't it be:
?Qt Code:
To copy to clipboard, switch view to plain text mode
J-P Nurmi
Bookmarks