I have a container std::map<std::string, unique_ptr<ItemWidget>> widgets
that contains pointers to my widgets, so all of my widgets exist separately and independend from QListWidget
object. Sometimes i need to hide some of widgets temporarily, sometimes to delete ones finally. So my code implements this:
ui->listWidget->clear()
for (auto it : widgets) {
auto item = new QListWidgetItem();
item->setSizeHint(it->size());
ui->listWidget->addItem(item);
ui->listWidget->setItemWidget(item, it);
}
Now i read that ui->listWidget->clear()
calls delete
for all list's items. And thats why my list has all items with no data.
I want to list to delete my widgets from itself, but without any impact to my widgets. Can i?
Aucun commentaire:
Enregistrer un commentaire