I have a QListWidget and I need to remove some elements.
From what I explored, this is generally an unpleasant thing.
I read a ton of solutions, but none of them apply to my specific scenario.
At the moment, I only have the actual Item widgets; not their values ββor index.
This is because I get the elements (need to be removed) through .selectedItems()
.
Here is the code:
ItemSelect = list(self.ListDialog.ContentList.selectedItems()) for x in range (0, len(ItemSelect)): print self.ListDialog.ContentList.removeItemWidget(ItemSelect[x])
It does nothing. This does not cause an error, but the selected items are not deleted.
The methods I saw to remove items require either an index or an item name, none of which I have. I only have actual widgets.
How to remove them?
Did I miss something?
I use:
Python 2.7.1
PyQt4 IDLE 1.8
Windows 7
source share