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. What is the best approach to save and restore widgets states?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 413 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.
  • E Offline
    E Offline
    efdiloreto
    wrote on last edited by
    #1

    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?

    JonBJ 1 Reply Last reply
    0
    • E efdiloreto

      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?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @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
      1
      • JonBJ JonB

        @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 Offline
        E Offline
        efdiloreto
        wrote on last edited by
        #3

        @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
        0

        • Login

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