[PyQt] using itemDoubleClicked with pyqt

Christopher M. Nahler christopher.nahler at papermodels.at
Wed Jun 23 08:40:09 BST 2010


I have problems using a signal. In the code below I create a QListWidget 
where I would like to act upon doubleClicking an item.

In the documentation I have found the signal "itemDoubleClicked".  
(http://doc.qt.nokia.com/4.6/qlistwidget.html#itemDoubleClicked)
But somehow I am not using it right. What am I doing wrong?

thanks in advance
Chris



import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *

itemList = ["One",
              "Two",
              "Three",
              "Four",
              "Five"]

class ListDlg(QDialog):

     def __init__(self, name, parent=None):
         super(ListDlg, self).__init__(parent)

         self.myList = QListWidget()
         self.myList.addItems(itemList)
         self.myList.setCurrentRow(0)

         layout = QHBoxLayout()
         layout.addWidget(self.myList)
         self.setLayout(layout)
         self.connect(self.myList, SIGNAL("itemDoubleClicked(*item)"), 
self.processItem)

     def processItem(self, item):
         print(item.text())

if __name__ == "__main__":
     app = QApplication(sys.argv)
     form = ListDlg("Listdialog")
     form.exec_()


More information about the PyQt mailing list