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 add file save functionality to a Qt application ?
Forum Updated to NodeBB v4.3 + New Features

How to add file save functionality to a Qt application ?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.7k Views 1 Watching
  • 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.
  • I Offline
    I Offline
    issam
    wrote on last edited by
    #1

    Hi,
    I am presently developing an application that allows the user to draw and test a Petri Net diagram. I am using the graphic View framework.
    I want to add to this application the capability to save (Shift+Ctrl+S) a drawn diagram as a file on the disk and to restore (Ctrl + O) it later.
    Is there an easy way to do that ? If I have to use XML, is there an XML-based language to do such as operations with diagrams ?

    http://www.iissam.com/

    1 Reply Last reply
    0
    • B Offline
      B Offline
      butterface
      wrote on last edited by
      #2

      There are whole applications doing that but however.
      If I would do it I would use some kind of text file (XML should be good for it) and write my own syntax because I have to read it again and would be able to do so. If you want to interchange with other software you have to have a look at their file formats. It would also be possible to write simple text files with the connections if that is suiteable for you and you can save the overhead of an XML file.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        KA51O
        wrote on last edited by
        #3

        I guess you already have a class or data struct to represent your diagram internally. You could just serialize this data using "QDataStream":http://qt-project.org/doc/qt-4.8/qdatastream.html or "boost::serialize":http://www.boost.org/doc/libs/1_51_0/libs/serialization/doc/index.html . Examples on how to serialize your data and on how to read it back into your internal data are provided in both links. I'm not sure about QDataStream but boost::serialize also provides versioning which comes in quite handy if you have to modifiy the data struct or class you're serializing and you already have released your product. This way you can support newer and older versions of your serialized data simultaniously.

        1 Reply Last reply
        0
        • I Offline
          I Offline
          issam
          wrote on last edited by
          #4

          It's Ok I used XML and it works well :)

          http://www.iissam.com/

          1 Reply Last reply
          0

          • Login

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