what is the best way to delete all QTreeWidgetItems in a QTreeWidget?
-
what is the best way to delete all QTreeWidgetItems in a QTreeWidget?
now i use QTreeWidget::clear(), but i doubt that there is some memory not released immediately..
thank you -
@opengpu2 said:
QTreeWidget::clear()
is the best way to do it.
void QTreeWidget::clear() { Q_D(QTreeWidget); selectionModel()->clear(); d->treeModel()->clear(); } void QTreeModel::clear() { SkipSorting skipSorting(this); beginResetModel(); for (int i = 0; i < rootItem->childCount(); ++i) { QTreeWidgetItem *item = rootItem->children.at(i); item->par = 0; item->view = 0; delete item; } rootItem->children.clear(); sortPendingTimer.stop(); endResetModel(); }