what is the best way to delete all childWidgetItem of QTreeWidgetItem recursively?
-
void MainWindow::delItemInTree(QTreeWidgetItem *item) { if (item == 0) return; QTreeWidgetItem *itemAbove = ui->treeWidget->itemAbove(item); if (itemAbove == 0) return; QTreeWidgetItem *parent = item->parent(); while (item->childCount() > 0) { QTreeWidgetItem *tmp = item->takeChild(0); tmp = 0; delete tmp; } int index = parent->indexOfChild(item); delete parent->takeChild(index); }