Whenever I click any function in the list widget, it ran a specific function. Now I want to send the item itself, as a parameter to that function. Here is the code:
QtCore.QObject.connect(self.listWidget, QtCore.SIGNAL("itemClicked(QListWidgetItem *)"), self.test)
def test(self):
print 'hello'
Instead I want:
def test(self,item):
print item
That should already work – when
itemClickedis emitted it sends the clickedQListWidgetItemas a parameter. You just need to edit yourtestfunction to accept an extra parameter, and that will be yourQListWidgetItem.In the above example you’ll see a QListWidget with three items. When you click an item the item along with the item’s text will be printed to the console.