pyQT question

Jim jbublitzNO at
Thu Oct 31 05:38:19 CET 2002

Scott Hathaway wrote:
> I am new to pyQT and I am trying to subclass this form and add items to the
> listbox.  Can anyone tell me what I am doing wrong?

>         self.dbList = QListView(self,'dbList')

>         self.dbList.insertStrList(dbs)
>         # here I have tried the following
>         # frmMain.dbList.insertItem(dbs[0])
>         # mForm.dbList.insertItem('test')

'insertStrList' is a QList*Box* method, not QList*View*.
QListView.insertItem takes a QListViewItem, not a
string. A QListBox holds a list of strings, a QListView
holds a list of QListViewItems. The similarity in
names is a little confusing.

lvItem = QListViewItem (self.dbList, "test")

should be all you need if you really want QListView.
You don't really need the "lvItem =" either, unless
you want to access the particular QListViewItem directly
  - the  constructor should insert it in the parent
(self.dbList), and the parent holds a reference to
the QListViewItem created.

Hopefully I read my own code correctly - if not,
the Qt docs are very good and you should consult those.


More information about the Python-list mailing list