Search code examples
c++qtqlistwidget

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


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.


Solution

  • Try

    qDeleteAll(listWidget->selectedItems());