One way is to create a recursive function that traverses the tree.
I assume you only want to save the data in the leaf nodes.
Qt Code:
  1. void SomeClass::traverseTree(QTreeWidgetItem root)
  2. {
  3. if( root && root->childCount())
  4. {
  5. int childCount = root->childCount();
  6. for( int i = 0; i != childCount(); i++ )
  7. traverseTree( root->child(i);
  8. //Assuming you have any extra data in items that are not terminal nodes,
  9. //then you can save it here.
  10. }
  11. else if( !root->childCount() ) //this means it is a leaf
  12. {
  13. //save whatever data you have in your item in the file.
  14. }
  15. }
To copy to clipboard, switch view to plain text mode 

This should pretty much work.

Regards