I'm not sure if I follow what you mean by the letters and numbers but isn't that a simple case of descending node traversal using a recursive call? First "visit" yourself, then visit each of your children in order by calling the same visiting function on them.
Something like:
list << item->text(0);
for(int i=0;i<item->childCount(); ++i)
visitTree(list, item->child(i));
}
for(int i=0;i<tree->topLevelItemCount();++i)
visitTree(list, tree->topLevelItem(i));
return list;
}
//...
void visitTree(QStringList &list, QTreeWidgetItem *item){
list << item->text(0);
for(int i=0;i<item->childCount(); ++i)
visitTree(list, item->child(i));
}
QStringList visitTree(QTreeWidget *tree) {
QStringList list;
for(int i=0;i<tree->topLevelItemCount();++i)
visitTree(list, tree->topLevelItem(i));
return list;
}
//...
QStringList result = visitTree(myTree);
To copy to clipboard, switch view to plain text mode
Bookmarks