[PyQt] SIGNAL("itemActivated(QListWidgetItem *)") problem

paolomilani at rocketmail.com paolomilani at rocketmail.com
Mon Jun 1 18:03:53 BST 2009

Hi! :)
I've a little problem with SIGNAL("itemActivated(QListWidgetItem *)").

When kde4.2.2 is set on double click mode, everything is ok, but when it's set on single click mode, I select items with ctrl+click and SIGNAL itemActivated is emitted.  Is it a bug? or is it my misunderstanding?

many thanks,

My system is kubuntu 9.04 (python 2.6.2, Qt 4.5.0, PyQT 4.4.4). Tested on amd64 and i386 platform.


#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyKDE4.kdeui import *

class ListWidgetTest(QDialog):
    def __init__(self, parent=None):
        super(ListWidgetTest, self).__init__(parent)

        listWidget = QListWidget()
        layout = QVBoxLayout()

        self.connect(listWidget, SIGNAL("itemClicked(QListWidgetItem *)"), self.printClicked)
        self.connect(listWidget, SIGNAL("itemActivated(QListWidgetItem *)"), self.printActivated)
        item0 = QListWidgetItem("0")
        item0.setData(Qt.UserRole, QVariant(1))
        item1 = QListWidgetItem("1")
        item1.setData(Qt.UserRole, QVariant(1))
        item2 = QListWidgetItem("2")
        item2.setData(Qt.UserRole, QVariant(1))
        listWidget.insertItem(0, item0)
        listWidget.insertItem(1, item1)
        listWidget.insertItem(2, item2)

    def printClicked(self, item):
        print "clicked", item.text()
    def printActivated(self, item):
        print "activated", item.text()

if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)
    dialog = ListWidgetTest()


More information about the PyQt mailing list