Reputation: 101
I want to add double clicked attribute for my QListWidget objects.
My command line does not work:
self.connect(self.listWidget, QtCore.SIGNAL("itemDoubleClicked(QtGui.QListWidgetItem)"), self.showItem)
How to add double clicked attribute ? How to give object parameter to QtCore.SIGNAL.
Upvotes: 6
Views: 15418
Reputation: 120738
The reason why the signal connection did not work, is that you are using the wrong signature for QListWidget.itemDoubleClicked. It should instead look like this:
self.connect(self.listWidget,
QtCore.SIGNAL("itemDoubleClicked(QListWidgetItem *)"),
self.showItem)
However, I would advise that you avoid using this method of connecting signals altogther, and switch to the new-style syntax instead. This would allow you to rewrite the above code like this:
self.listWidget.itemDoubleClicked.connect(self.showItem)
Which is not only simpler and cleaner, but also much less error-prone (in fact, an exception will be raised if the wrong signal name/signature is used).
Upvotes: 10