what is the best way to delete all QTreeWidgetItems in a QTreeWidget?
-
@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(); }