How do I remove all the selected items in a QListWidget?

sashoalm picture sashoalm · Aug 10, 2011 · Viewed 13.3k times · Source

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.

Answer

O.C. picture O.C. · Aug 10, 2011

Try

qDeleteAll(listWidget->selectedItems());