[PyKDE] subclassing QListViewItem

2003-10-27 Thread Peter Bienstman
-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?

Thanks!

- -- 
- 
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: [EMAIL PROTECTED]
- 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/nVTM4dgPAIjyquoRAi1zAJ48Ufq23JkbIkgja96Obrdyq2Pe2QCeI0Xq
fWz22T3CwG+YjiD67Z4Kqoc=
=5rfs
-END PGP SIGNATURE-

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] subclassing QListViewItem

2003-10-27 Thread Phil Thompson
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

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] subclassing QListViewItem

2003-10-27 Thread Peter Bienstman
-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: [EMAIL PROTECTED]
- 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/nV454dgPAIjyquoRAiIIAKDgT7GcVUfzU4TN2I02h42/+kuX3QCdHiG7
bEf4aqglq0SgUsQT8eDlsJg=
=36Wq
-END PGP SIGNATURE-

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde