Sorry, but what do you expect from us? What did YOU try so far? Have you seen the examples shipped with Qt/PyQt?
Sorry, but what do you expect from us? What did YOU try so far? Have you seen the examples shipped with Qt/PyQt?
J-P Nurmi
I haven't tried much to be honest. I was after ideas more than an implementation. From what I understand of QListWidget it works like an array, in which case the best idea i have so far is listing all values within the field and then adding them to the QListWidget. Then to find details on a specific bit doing a search through the database for that name, however this seems rather wasteful I was really after better understanding as to how QLIstWidget works.
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