Subclasses of QListViewItems: Re: [Fwd: Re: [PyKDE] Typecasting]

Boudewijn Rempt bsarempt at rempt.xs4all.nl
Wed Nov 15 21:08:31 GMT 2000


On Wed, 15 Nov 2000, Boudewijn Rempt wrote:

> On Tue, 14 Nov 2000, Mark Kimsal wrote:
> 
> > 
> > Yes it behaves exactly as I'd expect:
> > 
> > <qt.QListViewItem instance at 0079CD4C>
> > Traceback (most recent call last):
> >   File "qt/pyqt22/examples/dirview.py", line 66, in handleClick
> >     print itm, itm.f
> > AttributeError: f
> > 
> > Sub classes of QListViewItem are not passed from QListView SIGNALS
> > akaict.
> > 
> 
> Haven't we had this problem before? I sounds it's the same as in:
> http://www.mail-archive.com/pykde@mats.gmd.de/msg00305.html.
> 

I've just updated that test program, and it runs fine:

#!/usr/bin/env python

import os
import sys

from qt import *

class myListViewItem(QListViewItem):

  def __init__(self, parent):
    QListViewItem.__init__(self, parent)

  def slotHook(self):
    print "slotHook"

class frmListView(QListView):
  def __init__(self, parent=None):
    QListView.__init__(self, parent)

    self.addColumn("a", 200)
    self.addColumn("b", 200)

    self.rows=[]
    lvi=myListViewItem(self)

    lvi.setText(0, "xxxxx")
    lvi.setText(1, "yyyyy")
    self.rows.append(lvi)

    self.connect(self, SIGNAL("doubleClicked ( QListViewItem * )")
                     , self.slotOpenFile
                     )

  def slotOpenFile(self, item):
    print item
    self.currentItem().slotHook()

def main():

  qapp=QApplication(sys.argv)
  toplevel=frmListView()
  toplevel.show()
  qapp.connect(qapp, SIGNAL('lastWindowClosed()'), qapp, SLOT('quit()'))
  print qapp.exec_loop()
  
if __name__=="__main__":
  main()

 
                                                                                     
bash-2.03$ python qlsv_sig.py
<__main__.myListViewItem instance at 0x8240e6c>
<__main__.myListViewItem instance at 0x8240e6c>
slotHook
0 





More information about the PyQt mailing list