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. Please, remember int!
Forum Update on Monday, May 27th 2025

Please, remember int!

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 3.5k 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.
  • M Offline
    M Offline
    Miikukka
    wrote on last edited by
    #1

    I would like my app remember what each int mean, when I restart application.
    I mean that, when I have set "int Time = 3", it doesn't remember it if I restart app, and I think app should remember that.
    Can I use same function, if I make QStringList or is there some other function for it, and what is it?

    Is this possible and how to do this?
    Thank you!

    There are no stupid questions, only stupid answers.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      You can use "QSettings":http://developer.qt.nokia.com/doc/qt-4.7/qsettings.html for this purpose.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        You should read up on serialization in general. QSettings is one way to do that, but there are many more, like boost::serialize for instance.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Miikukka
          wrote on last edited by
          #4

          Hmmm... Could you write an example how to do that.
          Should I just write something like

          @QSettings::remember(Time)@

          (there isn't "remember" in fact, but you already knew that :D ), or how can I do it?

          There are no stupid questions, only stupid answers.

          1 Reply Last reply
          0
          • K Offline
            K Offline
            koahnig
            wrote on last edited by
            #5

            Did you have a look at the "QSettings":http://developer.qt.nokia.com/doc/qt-4.7/qsettings.html examples?
            The magic methods are setValue() and value().

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            0
            • M Offline
              M Offline
              Miikukka
              wrote on last edited by
              #6

              Yes I looked them.
              Can I do like this:¨
              @QSettings settings();
              settings.setValue("Time", 8);@
              Or what is wrong?

              There are no stupid questions, only stupid answers.

              1 Reply Last reply
              0
              • K Offline
                K Offline
                koahnig
                wrote on last edited by
                #7

                Based on the documentation this should be more like this.
                @
                QCoreApplication::setOrganizationName("Your organization");
                QCoreApplication::setApplicationName("Your-Program");
                QSettings settings;
                settings.setValue ("Time", 8 );
                @

                However, you should read the details. Especially concerning the operation system you are using.

                I am using QSettings typically with a specific file (*.ini). You might want to check the sequence given above.

                Do you get specific errors?

                Vote the answer(s) that helped you to solve your issue(s)

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #8

                  Why don't you just try what you want to do and report back your experiences? Looks a bit as if you ask for permission to add a line of code each time you have an idea...

                  QSettings usually works pretty flawless, so did you actually incorporate it in your code? Do you have any specific problems with that class?

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  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