tags:

views:

74

answers:

2

Hello!

Does Qt has something like QSettings, but for local scopes?

I am seeking for a data structure with the same methods, but not specific for APPLICATION.

I mean, I want to construct local (for example, exporting settings) settings from file (xml, for example) and use them in local scope - without polluting global application settings.

Is that possible (with QSettings or some other class)? How should I construct the object then?

+3  A: 

You can use

void QSettings::setPath ( Format format, Scope scope, const QString & path ) 

to set the format (as specified in the doc)

QSettings::NativeFormat 0 Store the settings using the most appropriate storage format for the platform. On Windows, this means the system registry; on Mac OS X, this means the CFPreferences API; on Unix, this means textual configuration files in INI format.

QSettings::IniFormat 1 Store the settings in INI files.

QSettings::InvalidFormat

the scope:

QSettings::UserScope 0 Store settings in a location specific to the current user (e.g., in the user's home directory).

QSettings::SystemScope 1 Store settings in a global location, so that all users on the same machine access the same set of settings.

So if you are on Windows and want to write User-specific settings, you would use the IniFormat and the UserScope values and specify the path where you want to write your settings in the path variable.

Hope this helps.

Live
A: 

You create a datastream and write the data into the file in member by member fashion.

Shadow