ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
from the Qt documentation
Detailed Description
The QSettings class provides persistent platform-independent application settings.
On Unix systems, QSettings uses text files to store settings.
On Windows systems, QSettings uses the system registry.
On Mac OS X, QSettings uses the Carbon preferences API.
Each setting comprises an identifying key and the data
associated with the key. A key is a unicode string which
consists of two or more subkeys. A subkey is a slash, '/',
followed by one or more unicode characters (excluding
slashes, newlines, carriage returns and equals, '=', signs).
The associated data, called the entry or value, may be
a boolean, an integer, a double, a string or a list of strings.
Entry strings may contain any unicode characters.
If you want to save and restore the entire desktop's settings,
i.e. which applications are running, use QSettings to save
the settings for each individual application and QSessionManager
to save the desktop's session.
In JAVA we have java.util.prefs.Preferences class which allows applications to store and retrieve user and system preferences and configuration data.
Is anything similar to this also available on C++? I want it particularly on linux platform.
Thanks in advance.
// Rahul
For constant values is good to have bunch of #define statements in one file, globals.h for example. For saved user configuration you can make a hidden directory in user's home directory and store ihs/her settings there. See how other apps such as Gaim do this.
The QSettings class provides persistent platform-independent application settings.
That QT class (probably) does what you want, but QT is a big library and requires even bigger X libraries. Use it only if your application already uses QT for other things. Otherwise, glib configuration file parser is better solution.
Quote:
Makes Java sound very nice.
The idea is nice, but the implementation is not. Java does not let you specify the path and name of the properties file, which makes it impossible to use standard unix/linux names /etc/appname and ~/.appname.
Originally posted by Harmaa Kettu
[B]That QT class (probably) does what you want, but QT is a big library and requires even bigger X libraries. Use it only if your application already uses QT for other things.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.