Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved What is the best approach to save and restore widgets states?

    General and Desktop
    2
    3
    127
    Loading More Posts
    • 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.
    • E
      efdiloreto last edited by

      For example, I am making desktop software and I want the user to be able to save a file (for example a project file) with the states of the widgets. Is QSetting a good option? Should I save it in some format like JSON to deserialize it later?

      JonB 1 Reply Last reply Reply Quote 0
      • JonB
        JonB @efdiloreto last edited by

        @efdiloreto
        You have to write any code to de/serialize widgets yourself. The question is, just how much do you intend to store from each widget, because widgets have an awful lot of properties!

        QSettings will store simple simple name=value pairs. If you're going to store a lot of data, JSON would give you more power/flexibility. Note that you can store any QSettings individual value as/in JSON, so you can get the best of both worlds, i.e. the convenience of QSettings file/registry handling with the structured data of JSON.

        E 1 Reply Last reply Reply Quote 1
        • E
          efdiloreto @JonB last edited by

          @JonB Thanks for the response. In that case I think I will do it with JSON. I only need to save / restore some widgets states and values.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post