Please, remember int!



  • 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!


  • Moderators

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



  • 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.



  • 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?


  • Moderators

    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().



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


  • Moderators

    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?



  • 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?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.