Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to serialize QAbstractItemModel in QDataStream?

How to serialize QAbstractItemModel in QDataStream?

Scheduled Pinned Locked Moved General and Desktop
qabstractitemmomvcserializationqdatastream
2 Posts 2 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ralf
    wrote on 27 Aug 2015, 06:32 last edited by
    #1

    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

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 27 Aug 2015, 20:50 last edited by
      #2

      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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      2/2

      27 Aug 2015, 20:50

      • Login

      • Login or register to search.
      2 out of 2
      • First post
        2/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved