On Unix systems, TQSettings uses text files to store settings. On Windows systems, TQSettings uses the system registry. On Mac OS X, TQSettings 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 \fItwo\fR 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 TQSettings to save the settings for each individual application and TQSessionManager to save the desktop's session.
\fBWarning:\fR Creating multiple, simultaneous instances of TQSettings writing to a text file may lead to data loss! This is a known issue which will be fixed in a future release of Qt.
At the time of writing settings are stored (either on a global or user basis, preferring locally) into a plist file in \fC$ROOT/System/Library/Preferences\fR (in XML format). TQSettings will create an appropriate plist file (\fCcom.<first group name>.plist\fR) out of the full path to a key.
For further information on CFPreferences see Apple's Specifications
.SH "Notes for Unix Applications"
There is no universally accepted place for storing application settings under Unix. In the examples the settings file will be searched for in the following directories: <ol type=1>
.TP
\fCSYSCONF\fR - the default value is \fCINSTALL/etc/settings\fR
\fC$HOME/.qt\fR When reading settings the files are searched in the order shown above, with later settings overriding earlier settings. Files for which the user doesn't have read permission are ignored. When saving settings TQSettings works in the order shown above, writing to the first settings file for which the user has write permission. (\fCINSTALL\fR is the directory where TQt was installed. This can be modified by using the configure script's -prefix argument )
will end up writing the "geometry/width" setting to the file \fC$HOME/.qt/myapplicationrc\fR (assuming that the application is being run by an ordinary user, i.e. not by root).
.PP
For cross-platform applications you should ensure that the Windows size limitations are not exceeded.
Creates a settings object. If \fIformat\fR is 'Ini' the settings will be stored in a text file, using the Unix strategy (see above). If \fIformat\fR is 'Native', the settings will be stored in a platform specific way (ie. the Windows registry).
In the above example, \fCkeys\fR will contain 'background color' and 'foreground color'. It will not contain 'geometry' because this key contains subkeys not entries.
.PP
To access the geometry values, you could either use subkeyList() to read the keys then read each entry, or simply read each entry directly by specifying its full key, e.g." /MyCompany/MyApplication/geometry/y".
Inserts \fIpath\fR into the settings search path. The semantics of \fIpath\fR depends on the system \fIs\fR. It is usually easier and better to use setPath() instead of this function.
.PP
When \fIs\fR is \fIWindows\fR and the execution environment is \fInot\fR Windows the function does nothing. Similarly when \fIs\fR is \fIUnix\fR and the execution environment is \fInot\fR Unix the function does nothing.
.PP
When \fIs\fR is \fIWindows\fR, and the execution environment is Windows, the search path list will be used as the first subfolder of the "Software" folder in the registry.
.PP
When reading settings the folders are searched forwards from the first folder (listed below) to the last, returning the first settings found, and ignoring any folders for which the user doesn't have read permission. <ol type=1>
settings.writeEntry( "/MyApplication/Tip of the day", TRUE );
.br
.fi
The code above will write the subkey "Tip of the day" into the \fIfirst\fR of the registry folders listed below that is found and for which the user has write permission. <ol type=1>
HKEY_CURRENT_USER/Software/MyApplication If a setting is found in the HKEY_CURRENT_USER space, this setting is overwritten independently of write permissions in the HKEY_LOCAL_MACHINE space.
.PP
When \fIs\fR is \fIUnix\fR, and the execution environment is Unix, the search path list will be used when trying to determine a suitable filename for reading and writing settings files. By default, there are two entries in the search path:
.PP
<ol type=1>
.TP
\fCSYSCONF\fR - where \fCSYSCONF\fR is a directory specified when configuring Qt; by default it is INSTALL/etc/settings.
.TP
\fC$HOME/.qt/\fR - where \fC$HOME\fR is the user's home directory.
.PP
All insertions into the search path will go before $HOME/.qt/. For example:
$HOME/.qt When reading settings the files are searched in the order shown above, with later settings overriding earlier settings. Files for which the user doesn't have read permission are ignored. When saving settings TQSettings works in the order shown above, writing to the first settings file for which the user has write permission.
Note that paths in the file system are not created by this function, so they must already exist to be useful.
.PP
Settings under Unix are stored in files whose names are based on the first subkey of the key (not including the search path). The algorithm for creating names is essentially: lowercase the first subkey, replace spaces with underscores and add 'rc', e.g. \fC/MyCompany/MyApplication/background color\fR will be stored in \fCmyapplicationrc\fR (assuming that \fC/MyCompany\fR is part of the search path).
Reads the entry specified by \fIkey\fR, and returns a bool, or the default value, \fIdef\fR, if the entry couldn't be read. If \fIok\fR is non-null, *ok is set to TRUE if the key was read, FALSE otherwise.
.PP
See also readEntry(), readNumEntry(), readDoubleEntry(), writeEntry(), and removeEntry().
Reads the entry specified by \fIkey\fR, and returns a double, or the default value, \fIdef\fR, if the entry couldn't be read. If \fIok\fR is non-null, *ok is set to TRUE if the key was read, FALSE otherwise.
.PP
See also readEntry(), readNumEntry(), readBoolEntry(), writeEntry(), and removeEntry().
Reads the entry specified by \fIkey\fR, and returns a TQString, or the default value, \fIdef\fR, if the entry couldn't be read. If \fIok\fR is non-null, *ok is set to TRUE if the key was read, FALSE otherwise.
Reads the entry specified by \fIkey\fR as a string. If \fIok\fR is not 0, \fI*ok\fR is set to TRUE if the key was read, otherwise \fI*ok\fR is set to FALSE.
.PP
Note that if you want to iterate over the list, you should iterate over a copy, e.g.
Reads the entry specified by \fIkey\fR as a string. The \fIseparator\fR is used to create a TQStringList by calling TQStringList::split(\fIseparator\fR, entry). If \fIok\fR is not 0: \fI*ok\fR is set to TRUE if the key was read, otherwise \fI*ok\fR is set to FALSE.
\fBWarning:\fR As the documentation states, TQStringList::split() will omit empty strings from the list. Because of this, it is impossible to retrieve identical list data with this function. We recommend using the readListEntry() and writeEntry() overloads that do not take a \fIseparator\fR argument.
Reads the entry specified by \fIkey\fR, and returns an integer, or the default value, \fIdef\fR, if the entry couldn't be read. If \fIok\fR is non-null, *ok is set to TRUE if the key was read, FALSE otherwise.
.PP
See also readEntry(), readDoubleEntry(), readBoolEntry(), writeEntry(), and removeEntry().
Returns true if the entry was successfully removed; otherwise returns false. Note that removing the last entry in any given folder, will also remove the folder.
Removes all occurrences of \fIpath\fR (using exact matching) from the settings search path for system \fIs\fR. Note that the default search paths cannot be removed.
The \fIscope\fR should be TQSettings::User for user-specific settings, or TQSettings::Global for system-wide settings (generally these will be read-only to many users).
In the above example, \fCkeys\fR will contain 'geometry' and 'recent files'. It will not contain 'background color' or 'foreground color' because those keys contain entries not subkeys. To get a list of keys that contain entries rather than subkeys use entryList() instead.
is written to the file \fI"mycompanyrc"\fR, under the section \fI[MyApplication]\fR. This call is therefore a request to list the sections in an ini file, which is not supported in this version of TQSettings. This is a known issue which will be fixed in Qt-4.
Writes the boolean entry \fIvalue\fR into key \fIkey\fR. The \fIkey\fR is created if it doesn't exist. Any previous value is overwritten by \fIvalue\fR.
.PP
If an error occurs the settings are left unchanged and FALSE is returned; otherwise TRUE is returned.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Writes the double entry \fIvalue\fR into key \fIkey\fR. The \fIkey\fR is created if it doesn't exist. Any previous value is overwritten by \fIvalue\fR.
.PP
If an error occurs the settings are left unchanged and FALSE is returned; otherwise TRUE is returned.
.PP
See also readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), and removeEntry().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Writes the integer entry \fIvalue\fR into key \fIkey\fR. The \fIkey\fR is created if it doesn't exist. Any previous value is overwritten by \fIvalue\fR.
.PP
If an error occurs the settings are left unchanged and FALSE is returned; otherwise TRUE is returned.
.PP
See also readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), and removeEntry().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Writes the string entry \fIvalue\fR into key \fIkey\fR. The \fIkey\fR is created if it doesn't exist. Any previous value is overwritten by \fIvalue\fR. If \fIvalue\fR is an empty string or a null string the key's value will be an empty string.
.PP
If an error occurs the settings are left unchanged and FALSE is returned; otherwise TRUE is returned.
.PP
See also readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), and removeEntry().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Writes the string list entry \fIvalue\fR into key \fIkey\fR. The \fIkey\fR is created if it doesn't exist. Any previous value is overwritten by \fIvalue\fR.
.PP
If an error occurs the settings are left unchanged and FALSE is returned; otherwise returns TRUE.
.PP
See also readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), and removeEntry().
Writes the string list entry \fIvalue\fR into key \fIkey\fR. The \fIkey\fR is created if it doesn't exist. Any previous value is overwritten by \fIvalue\fR. The list is stored as a sequence of strings separated by \fIseparator\fR (using TQStringList::join()), so none of the strings in the list should contain the separator. If the list is empty or null the key's value will be an empty string.
\fBWarning:\fR The list should not contain empty or null strings, as readListEntry() will use TQStringList::split() to recreate the list. As the documentation states, TQStringList::split() will omit empty strings from the list. Because of this, it is impossible to retrieve identical list data that is stored with this function. We recommend using the writeEntry() and readListEntry() overloads that do not take a \fIseparator\fR argument.