I have QListWidget in my app, I need to get string value of item from QListWidget on which user has double clicked (activated item).
QtCore.QObject.connect(self.ui.listWidget, QtCore.SIGNAL("itemActivated (QListWidgetItem *)"), self.cas_dialog_spust)
def cas_dialog_spust(self):
predmet = QtGui.QListWidget.currentItem(QtGui.QListWidget())
print(predmet)
strpredmet = QtGui.QListWidgetItem.text(QtGui.QListWidgetItem(predmet))
print(strpredmet)
When I actually run this I double click on Item in QListWidget, predmet is None and I really don’t know why.
You don’t seem to understand the API calls you need to get the text of a
QListWidgetItem.currentItem()returns aQListWidgetItem, andtext()returns a string; both don’t take any arguments. Here’s a little application that does exactly what you request; let me know if you need any clarification.