Reputation: 79685
QListWidget::selectedItems returns a list of QListWidgetItem, but the only function for removing an item that I found is takeItem, which accepts only indexes, and selectedIndexes function is protected.
Upvotes: 12
Views: 13953
Reputation: 3970
Iterate through the SelectedItemsList:
QList<QListWidgetItem *> itemList = widget->selectedItems();
for (int i=0; i<itemList.size(); i++) {
widget->takeItem(widget->indexFromItem(itemList[i]));
}
I think
widget->removeItemWidget(itemList[i]);
may also work
Upvotes: 3