Qt Code:
  1. void MainWindow::expandNode(const QModelIndex &parentIndex, bool expand) {
  2. tree->setExpanded(parentIndex, expand);
  3. for (qint32 rowNum = 0; rowNum < treeModel->rowCount(parentIndex); ++rowNum) {
  4. QModelIndex childIndex = treeModel->index(rowNum, 0, parentIndex);
  5. tree->setExpanded(childIndex, expand);
  6. expandNode(childIndex);
  7. }
  8. }
To copy to clipboard, switch view to plain text mode