I recently spent some time working out how to use a QDataStream with a QTreeWidget in PyQt. I never found specific examples for doing exactly this, and pyqt documentation for QDataStream seems to be pretty scarce in general. So I thought I'd post a question here as a breadcrumb trail in case someone else down the line needs a hint. I'll wait a bit in case someone would like to jump in and take a shot at it, and I'll post back in a bit with my own efforts.

The question is: In PyQt, how can I use a QDataStream to save QTreeWidgetItems to a file as native QT objects, and then read the file back to restore the tree structure exactly as it was saved?

Eric