How to remove selected items from qlistWidget
.
I have tried write the following code, but does not work.
QList<QListWidgetItem*> items = ui->listWidget->selectedItems();
foreach(QListWidgetItem item, items){
ui->listWidget->removeItemWidget(item);
}
Now, how to remove the items that I selected from the qlistWidget
?
To give a solution with
removeItemWidget
:One way to remove item from
QListWidget
is to useQListWidget::takeItem
which removes and returns the item :Another way is to
qDeleteAll
: