[PyKDE] QListView

Frido Ferdinand frido at euronet.nl
Tue Sep 19 14:43:03 BST 2000


Hi,

(Cut & Paste from the archive)

Luis M. Gallardo D (Wed, 30 Aug 2000):

> Hi. I've tried to use a QListView, but I had some problems. I'm
> going to explain what I'm doing. I'm making a application that allow
> me list a directory from my PC and from a HP calculator (using
> Kermit protocol).  I'm going to show my Python Code:

.[snip]..

> 1) I have tried to connect dobleClicked() signal with DirPC
> (QListView), but I've able to do it. Qt Documentation specifies that
> there is a dobleClicked() signal, but when I include this signal I
> get a "No such signal QListView::doubleClicked()"  message.

The same problem occurs here when use the clicked() signal with a
QListView. Test script attached. Has anyone had the same problem
or has anyone got this to work with clicked() ?

thx,

            Frido Ferdinand 
-------------- next part --------------
#!/usr/bin/python

import sys
from qt import *

class testclick(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self, None , 'testclickt', Qt.WDestructiveClose)
        self.resize(270,480)
        self.Groups_View = QListView(self,'Groups_View')
        self.Groups_View.addColumn(self.tr('foo header'), 120)
        self.Groups_View.addColumn(self.tr('bar header'), 120)
        self.Groups_View.setGeometry(QRect(10,10,250,440))
        self.Groups_View.setSelectionMode(QListView.Extended)
        self.Groups_View.setAllColumnsShowFocus(1)
        # this works
        self.Groups_View.connect(self.Groups_View, SIGNAL("selectionChanged()"), self.slotTest)
        # self.Groups_View.connect(self.Groups_View, SIGNAL("clicked()"), self.slotTest)
        # Gives: 
        # QObject::connect: No such signal QObject::clicked()
        # QObject::connect:  (sender name:   'Groups_View')
        # QObject::connect:  (receiver name: 'unnamed')

        self.item = []
        self.counter = 0
        for i in [("foo 1", "bar 1"), ("foo 2", "bar 2")]:
            self.item.append(QListViewItem(self.Groups_View,None))
            self.item[self.counter].setText(0, i[0])
            self.item[self.counter].setText(1, i[1])
            self.counter = self.counter + 1

    def slotTest(self):
        print self.Groups_View.currentItem().text(0)

a = QApplication(sys.argv)

mw = testclick()
mw.show()

a.connect(a, SIGNAL('lastWindowClosed()'), a, SLOT('quit()'))
a.exec_loop()


More information about the PyQt mailing list