[PyQt] using itemDoubleClicked with pyqt

Zoltan Szalai flc at freemail.hu
Wed Jun 23 09:51:12 BST 2010


use:
self.myList.itemDoubleClicked.connect(self.processItem)

or:
self.connect(self.myList, SIGNAL("itemDoubleClicked(QListWidgetItem 
*)"), self.processItem)

both work fine here

regards
Zoltan

Christopher M. Nahler wrote:
>
> On 23.06.2010 09:46, Phil Thompson wrote:
>>  On Wed, 23 Jun 2010 09:40:09 +0200, "Christopher M. Nahler"
>>  <christopher.nahler at papermodels.at>   wrote:
>>
>>>  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_()
>>>
>>  The signal signature is "itemDoubleClicked(QListWidgetItem *)"
>>
>>  Phil
>>
> The way I understand this is that the signal passes a pointer to an
> item, right? So what is the correct way to setup the connection? I have
> tried with SIGNAL("itemDoubleClicked(item*)" and
> SIGNAL("itemDoubleClicked(item *)" but that also did not work.
>



More information about the PyQt mailing list