I have a Qlistwidget
in which I can select multiple items. I can get a list with all the selected items in the listwidget but can not find a way to get a list of the corresponding rows. To get a list of the selected items in the listwidget I used the following code:
print [str(x.text()) for x in self.listWidget.selectedItems()]
To retrieve the rows I am looking for something like:
a = self.listWidget.selectedIndexes()
print a
But this does not work. I have also tried some code which resulted in outputs like this, which is not very useful:
<PyQt4.QtGui.QListWidgetItem object at 0x0000000013048B88>
<PyQt4.QtCore.QModelIndex object at 0x0000000014FBA7B8>