I'm trying to come up with a way to write a tree model to a file. My tree model has child items that can have child items and so on. The problem is each parent item doesn't know the depth of its "branch" of the tree which makes iterating through the model difficult. You'd think that you could just check if an item has children and write those, but then you would have to account for child items having child items leaving you with an infinite amount of for statements. Anyways, is there some sort of method for writing these kind of data models to a file using QDataStream?