[PyKDE] subclassing QListViewItem
Peter Bienstman
Peter.Bienstman at ugent.be
Mon Oct 27 19:06:00 GMT 2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Monday 27 October 2003 18:51, you wrote:
> On Monday 27 October 2003 5:24 pm, Peter Bienstman wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Hi all,
> >
> > The following code works as expected:
> >
> > QListViewItem(self.element_list, "foo")
> >
> > But now I'm trying to subclass a QListViewItem:
> >
> > class ElementItem(QListViewItem):
> > def __init__(self, parent, elem):
> > QListViewItem.__init__(parent, "foo") # line x
> > ...
> >
> > If I try this:
> >
> > ElementItem(self.element_list, elem)
> >
> > I get:
> >
> > line x: TypeError: unbound method __init__() must be called with
> > QListViewItem instance as first argument (got QListView instance instead)
> >
> > But I was able to give it a QListView as first constructor argument when
> > I created the ListViewItems directly.
> >
> > Am I missing something?
>
> The error message you are getting describes exactly what is wrong.
>
> Pass "self" to QListViewItem.__init__().
>
> Phil
Doh, I knew that! Programming too long in a row is bad for productivity...
Thanks everyone for the quick reply,
Peter
- --
- ------------------------------------------------
Peter Bienstman
Ghent University, Dep. of Information Technology
Sint-Pietersnieuwstraat 41, B-9000 Gent, Belgium
tel: +32 9 264 34 45, fax: +32 9 264 35 93
WWW: http://photonics.intec.ugent.be
email: Peter.Bienstman at ugent.be
- ------------------------------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQE/nV454dgPAIjyquoRAiIIAKDgT7GcVUfzU4TN2I02h42/+kuX3QCdHiG7
bEf4aqglq0SgUsQT8eDlsJg=
=36Wq
-----END PGP SIGNATURE-----
More information about the PyQt
mailing list