Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions
Ensure garbage collection on QListWidget items.
teux last edited by teux
Does QListWidget::clear() delete all dynamically allocated elements it contains in Qt4.8? I'm not sure how to interpret the documentation, and I want to ensure I'm doing this properly.
I populate my list with custom QWidget HistoryItem as shown:
HistoryItem *historyItem = new HistoryItem(this, ...some data parameters...); QListWidgetItem *qlwItem = new QListWidgetItem(); qlwItem->setSizeHint(QSize(0, 70)); ui->listWidget->addItem(qlwItem); ui->listWidget->setItemWidget(qlwItem, historyItem);
I'm not worried about the HistoryItems as they get a pointer to the parent QWidget. But the QListWidgetItems don't have that. If they're not deleted with QListWidget::clear(), can I use QListWidget::itemFromIndex() to get the pointers for deletion? Is that the correct procedure?
Thank you for the help.
And I know 4.8 is OLD. (Sorry!) Porting to 5 will happen in the future, but it's not feasible at the moment for toolchain and time reasons.
As the warning state, all items are deleted.