As the title says, is there a way to get the amount of QTreeWidgetItems in a QTreeWidget?

Is there also a way to get a specified item by its location in the QTreeWidget? For example:
Qt Code:
  1. QTreeWidget* tree = new QTreeWidget();
  2. int index = tree->addTopLevelItem(item);
  3. QTreeWidgetItem* itemAtIndex = tree->getItemAtIndex(index);
  4. if(item == itemAtIndex)
  5. cout << "works!";
  6. int amount = tree->getItemCount();
  7. for(int i = 0; i < amount; i++)
  8. cout << tree->getItemAtIndex(i).text(0).toStdString();
To copy to clipboard, switch view to plain text mode