Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[Moved] does QTableWidget::clear() also delete QTableWidgetItems ?
bergerbits last edited by
I have a QTableWidget which I dynamically build and re-biuld.
I call MyClass::reset() on every re-build where I do QTableWidget::clear ().
Does that also clear (ie free memory) for every QTableWidgetItem constructed for table's cells?
Or do I need to delete these explicitly?
Here's a code snippet
QTableWidgetItem *ChannelItem = new QTableWidgetItem(tr("%1").arg(chan+1));
... a lot more of these
tableWidget_channels->clearContents(); // are items deleted too?
Franzk last edited by
QTableWidget takes ownership of these items, so you can rely on the items being deleted properly.