void DeleteChildNodes(const QModelIndex& parentIndex)
{
if (!parentIndex.isValid())
{
return;
}
QAbstractItemModel* model = m_pTreeView->model();
// 删除给定节点的所有子节点
int childCount = model->rowCount(parentIndex);
for (int i = 0; i < childCount; i++)
{
QModelIndex childIndex = parentIndex.child(i, 0);
DeleteChildNodes(childIndex);
model->removeRow(i, parentIndex);
}
// 删除给定节点本身
model->removeRow(parentIndex.row(), parentIndex.parent());
}
7037

被折叠的 条评论
为什么被折叠?



