How to serialize QAbstractItemModel in QDataStream?
-
Hello, I have a class MyModel derived from QAbstractItemModel. There I parse a file and store all relevant values. When I set that model to a QTreeView::setModel(myModel); everything is displayed properly.
I would like to store of my current MyModel object serialized/binary and load it again back from that file.How would that be possible?
Do I really have to visit all Items of that model?
Is there a example somewhere?Thnx in advance
Ralf -
Hi,
There's no ready made code to dump your model since only you know what make sense to dump. So yes you'll have to write the dumper and loader yourself. QDataStream comes to mind for that task.
Hope it helps