What are the benefits of QSettings class?



  • hi,

    i've seen in a lot of application that the developer uses a QSettings class form store some information.
    from the reference of the class, i've read in the description that it is a platform indipendent machanism to store information.
    I've not understand what it means: how can I use it in a application? Closing the application all data are lost?
    What could be an example of use? thanks


  • Lifetime Qt Champion

    Hi,

    As the name suggest, QSettings allows you to store settings for your application. i.e a window position, the value of a QComboBox or whatever you would like to store/restore when you close/restart your application.

    Hope it helps



  • "QSettings documentation":http://qt-project.org/doc/qt-5.0/qtcore/qsettings.html

    This is detailed enough. QSettings can be used more easily application wide. Even if going for a file rather than say registry entry, the normal serialization procedure involving QDataStream, etc, is very easily broken if not designed right. Using sqllite as a database is too complex for most application users.
    QSettings provides a tree level variant based storing mechanism without file stream order worries or details of sqllite db.



  • Thank you so much.
    My doubt is also about how it is performed: where these data are stored?
    I think in a file, but where is located this file?
    tnk
    [quote author="SGaist" date="1377100862"]Hi,

    As the name suggest, QSettings allows you to store settings for your application. i.e a window position, the value of a QComboBox or whatever you would like to store/restore when you close/restart your application.

    Hope it helps[/quote]


  • Moderators

    [quote author="mikecurl91" date="1377101060"]where these data are stored?
    I think in a file, but where is located this file?
    [/quote]

    It depends on the OS. On windows either in the good old ini-file or in the registry. Checkout the "documentation on the specifics.":http://qt-project.org/doc/qt-5.0/qtcore/qsettings.html#platform-specific-notes

    [quote author="mikecurl91" date="1377101060"]
    My doubt is also about how it is performed
    [/quote]
    the ini-file mode it is ASCII. There are certainly faster ways to do. However, in general it is not really an issue, since it is not supposed to store MB to GB of data.


Log in to reply
 

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