QListWidget删除Item及itemWidget
程序员文章站
2022-06-08 23:47:14
...
void Tool::clearListWidget(QListWidget *listWidget)
{
while (0 != listWidget->count())
{
QListWidgetItem *item = listWidget->item(0);
QWidget *widget = listWidget->itemWidget(item);
if (nullptr != widget)
{
listWidget->removeItemWidget(item);
widget->deleteLater();
}
item = listWidget->takeItem(0);
delete item;
item = nullptr;
}
}