You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
655 lines
26 KiB
655 lines
26 KiB
'\" t
|
|
.TH QSettings 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
|
|
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
|
|
.\" license file included in the distribution for a complete license
|
|
.\" statement.
|
|
.\"
|
|
.ad l
|
|
.nh
|
|
.SH NAME
|
|
QSettings \- Persistent platform-independent application settings
|
|
.SH SYNOPSIS
|
|
\fC#include <ntqsettings.h>\fR
|
|
.PP
|
|
.SS "Public Members"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "enum \fBFormat\fR { Native = 0, Ini }"
|
|
.br
|
|
.ti -1c
|
|
.BI "enum \fBSystem\fR { Unix = 0, Windows, Mac }"
|
|
.br
|
|
.ti -1c
|
|
.BI "enum \fBScope\fR { User, Global }"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBQSettings\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBQSettings\fR ( Format format )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fB~QSettings\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBwriteEntry\fR ( const QString & key, bool value )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBwriteEntry\fR ( const QString & key, double value )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBwriteEntry\fR ( const QString & key, int value )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBwriteEntry\fR ( const QString & key, const QString & value )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBwriteEntry\fR ( const QString & key, const QStringList & value )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool writeEntry ( const QString & key, const QStringList & value, const QChar & separator ) \fI(obsolete)\fR"
|
|
.br
|
|
.ti -1c
|
|
.BI "QStringList \fBentryList\fR ( const QString & key ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "QStringList \fBsubkeyList\fR ( const QString & key ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "QStringList \fBreadListEntry\fR ( const QString & key, bool * ok = 0 ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "QStringList readListEntry ( const QString & key, const QChar & separator, bool * ok = 0 ) const \fI(obsolete)\fR"
|
|
.br
|
|
.ti -1c
|
|
.BI "QString \fBreadEntry\fR ( const QString & key, const QString & def = QString::null, bool * ok = 0 ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBreadNumEntry\fR ( const QString & key, int def = 0, bool * ok = 0 ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "double \fBreadDoubleEntry\fR ( const QString & key, double def = 0, bool * ok = 0 ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBreadBoolEntry\fR ( const QString & key, bool def = FALSE, bool * ok = 0 ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBremoveEntry\fR ( const QString & key )"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBinsertSearchPath\fR ( System s, const QString & path )"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBremoveSearchPath\fR ( System s, const QString & path )"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBsetPath\fR ( const QString & domain, const QString & product, Scope scope = Global )"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBbeginGroup\fR ( const QString & group )"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBendGroup\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBresetGroup\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "QString \fBgroup\fR () const"
|
|
.br
|
|
.in -1c
|
|
.SH DESCRIPTION
|
|
The QSettings class provides persistent platform-independent application settings.
|
|
.PP
|
|
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.
|
|
.PP
|
|
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.
|
|
.PP
|
|
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.
|
|
.PP
|
|
Example settings:
|
|
.PP
|
|
.nf
|
|
.br
|
|
/MyCompany/MyApplication/background color
|
|
.br
|
|
/MyCompany/MyApplication/foreground color
|
|
.br
|
|
/MyCompany/MyApplication/geometry/x
|
|
.br
|
|
/MyCompany/MyApplication/geometry/y
|
|
.br
|
|
/MyCompany/MyApplication/geometry/width
|
|
.br
|
|
/MyCompany/MyApplication/geometry/height
|
|
.br
|
|
/MyCompany/MyApplication/recent files/1
|
|
.br
|
|
/MyCompany/MyApplication/recent files/2
|
|
.br
|
|
/MyCompany/MyApplication/recent files/3
|
|
.br
|
|
.fi
|
|
Each line above is a complete key, made up of subkeys.
|
|
.PP
|
|
A typical usage pattern for reading settings at application startup:
|
|
.PP
|
|
.nf
|
|
.br
|
|
QSettings settings;
|
|
.br
|
|
settings.setPath( "MyCompany.com", "MyApplication" );
|
|
.br
|
|
.br
|
|
QString bgColor = settings.readEntry( "/colors/background", "white" );
|
|
.br
|
|
int width = settings.readNumEntry( "/geometry/width", 640 );
|
|
.br
|
|
// ...
|
|
.br
|
|
.fi
|
|
.PP
|
|
A typical usage pattern for saving settings at application exit or 'save preferences':
|
|
.PP
|
|
.nf
|
|
.br
|
|
QSettings settings;
|
|
.br
|
|
settings.setPath( "MyCompany.com", "MyApplication" );
|
|
.br
|
|
.br
|
|
settings.writeEntry( "/colors/background", bgColor );
|
|
.br
|
|
settings.writeEntry( "/geometry/width", width );
|
|
.br
|
|
// ...
|
|
.br
|
|
.fi
|
|
.PP
|
|
A key prefix can be prepended to all keys using beginGroup(). The application of the prefix is stopped using endGroup(). For example:
|
|
.PP
|
|
.nf
|
|
.br
|
|
QSettings settings;
|
|
.br
|
|
.br
|
|
settings.beginGroup( "/MainWindow" );
|
|
.br
|
|
settings.beginGroup( "/Geometry" );
|
|
.br
|
|
int x = settings.readEntry( "/x" );
|
|
.br
|
|
// ...
|
|
.br
|
|
settings.endGroup();
|
|
.br
|
|
settings.beginGroup( "/Toolbars" );
|
|
.br
|
|
// ...
|
|
.br
|
|
settings.endGroup();
|
|
.br
|
|
settings.endGroup();
|
|
.br
|
|
.fi
|
|
.PP
|
|
You can get a list of entry-holding keys by calling entryList(), and a list of key-holding keys using subkeyList().
|
|
.PP
|
|
.nf
|
|
.br
|
|
QStringList keys = settings.entryList( "/MyApplication" );
|
|
.br
|
|
// keys contains 'background color' and 'foreground color'.
|
|
.br
|
|
.br
|
|
QStringList keys = settings.entryList( "/MyApplication/recent files" );
|
|
.br
|
|
// keys contains '1', '2' and '3'.
|
|
.br
|
|
.br
|
|
QStringList subkeys = settings.subkeyList( "/MyApplication" );
|
|
.br
|
|
// subkeys contains 'geometry' and 'recent files'
|
|
.br
|
|
.br
|
|
QStringList subkeys = settings.subkeyList( "/MyApplication/recent files" );
|
|
.br
|
|
// subkeys is empty.
|
|
.br
|
|
.fi
|
|
.PP
|
|
Since settings for Windows are stored in the registry there are some size limitations as follows:
|
|
.TP
|
|
A subkey may not exceed 255 characters.
|
|
.TP
|
|
An entry's value may not exceed 16,300 characters.
|
|
.TP
|
|
All the values of a key (for example, all the 'recent files' subkeys values), may not exceed 65,535 characters.
|
|
.PP
|
|
These limitations are not enforced on Unix or Mac OS X.
|
|
.PP
|
|
\fBWarning:\fR Creating multiple, simultaneous instances of QSettings 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.
|
|
.SH "Notes for Mac OS X Applications"
|
|
The location where settings are stored is not formally defined by the CFPreferences API.
|
|
.PP
|
|
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). QSettings will create an appropriate plist file (\fCcom.<first group name>.plist\fR) out of the full path to a key.
|
|
.PP
|
|
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
|
|
.TP
|
|
\fC/opt/MyCompany/share/etc\fR
|
|
.TP
|
|
\fC/opt/MyCompany/share/MyApplication/etc\fR
|
|
.TP
|
|
\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 QSettings 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 )
|
|
.PP
|
|
If you want to put the settings in a particular place in the filesystem you could do this:
|
|
.PP
|
|
.nf
|
|
.br
|
|
settings.insertSearchPath( QSettings::Unix, "/opt/MyCompany/share" );
|
|
.br
|
|
.fi
|
|
.PP
|
|
But in practice you may prefer not to use a search path for Unix. For example the following code:
|
|
.PP
|
|
.nf
|
|
.br
|
|
settings.writeEntry( "/MyApplication/geometry/width", width );
|
|
.br
|
|
.fi
|
|
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.
|
|
.PP
|
|
\fBWarning:\fR QSettings doesn't write the settings until it is destroyed so you should construct the QSettings object on the stack.
|
|
.PP
|
|
See also Input/Output and Networking and Miscellaneous Classes.
|
|
.SS "Member Type Documentation"
|
|
.SH "QSettings::Format"
|
|
.TP
|
|
\fCQSettings::Native\fR - Store the settings in a platform dependent location
|
|
.TP
|
|
\fCQSettings::Ini\fR - Store the settings in a text file
|
|
.SH "QSettings::Scope"
|
|
.TP
|
|
\fCQSettings::Global\fR - Save settings as global as possible
|
|
.TP
|
|
\fCQSettings::User\fR - Save settings in user space
|
|
.SH "QSettings::System"
|
|
.TP
|
|
\fCQSettings::Mac\fR - Macintosh execution environments
|
|
.TP
|
|
\fCQSettings::Unix\fR - Mac OS X, Unix, Linux and Unix-like execution environments
|
|
.TP
|
|
\fCQSettings::Windows\fR - Windows execution environments
|
|
.SH MEMBER FUNCTION DOCUMENTATION
|
|
.SH "QSettings::QSettings ()"
|
|
Creates a settings object.
|
|
.PP
|
|
Be aware that you must call setPath() or insertSearchPath() before you can use the QSettings object.
|
|
.SH "QSettings::QSettings ( Format format )"
|
|
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).
|
|
.PP
|
|
Be aware that you must call setPath() or insertSearchPath() before you can use the QSettings object.
|
|
.SH "QSettings::~QSettings ()"
|
|
Destroys the settings object. All modifications made to the settings will automatically be saved.
|
|
.SH "void QSettings::beginGroup ( const QString & group )"
|
|
Appends \fIgroup\fR to the current key prefix.
|
|
.PP
|
|
.nf
|
|
.br
|
|
QSettings settings;
|
|
.br
|
|
settings.beginGroup( "/MainWindow" );
|
|
.br
|
|
// read values
|
|
.br
|
|
settings.endGroup();
|
|
.br
|
|
.fi
|
|
.SH "void QSettings::endGroup ()"
|
|
Undo previous calls to beginGroup(). Note that a single beginGroup("a/b/c") is undone by a single call to endGroup().
|
|
.PP
|
|
.nf
|
|
.br
|
|
QSettings settings;
|
|
.br
|
|
settings.beginGroup( "/MainWindow/Geometry" );
|
|
.br
|
|
// read values
|
|
.br
|
|
settings.endGroup();
|
|
.br
|
|
.fi
|
|
.SH "QStringList QSettings::entryList ( const QString & key ) const"
|
|
Returns a list of the keys which contain entries under \fIkey\fR. Does \fInot\fR return any keys that contain subkeys.
|
|
.PP
|
|
Example settings:
|
|
.PP
|
|
.nf
|
|
.br
|
|
/MyCompany/MyApplication/background color
|
|
.br
|
|
/MyCompany/MyApplication/foreground color
|
|
.br
|
|
/MyCompany/MyApplication/geometry/x
|
|
.br
|
|
/MyCompany/MyApplication/geometry/y
|
|
.br
|
|
/MyCompany/MyApplication/geometry/width
|
|
.br
|
|
/MyCompany/MyApplication/geometry/height
|
|
.br
|
|
.fi
|
|
.PP
|
|
.nf
|
|
.br
|
|
QStringList keys = settings.entryList( "/MyCompany/MyApplication" );
|
|
.br
|
|
.fi
|
|
.PP
|
|
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".
|
|
.PP
|
|
See also subkeyList().
|
|
.SH "QString QSettings::group () const"
|
|
Returns the current key prefix, or a null string if there is no key prefix set.
|
|
.PP
|
|
See also beginGroup().
|
|
.SH "void QSettings::insertSearchPath ( System s, const QString & path )"
|
|
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>
|
|
.TP
|
|
HKEY_CURRENT_USER/Software/MyCompany/MyApplication
|
|
.TP
|
|
HKEY_LOCAL_MACHINE/Software/MyCompany/MyApplication
|
|
.TP
|
|
HKEY_CURRENT_USER/Software/MyApplication
|
|
.TP
|
|
HKEY_LOCAL_MACHINE/Software/MyApplication
|
|
.PP
|
|
.nf
|
|
.br
|
|
QSettings settings;
|
|
.br
|
|
settings.insertSearchPath( QSettings::Windows, "/MyCompany" );
|
|
.br
|
|
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>
|
|
.TP
|
|
HKEY_LOCAL_MACHINE/Software/MyCompany/MyApplication
|
|
.TP
|
|
HKEY_CURRENT_USER/Software/MyCompany/MyApplication
|
|
.TP
|
|
HKEY_LOCAL_MACHINE/Software/MyApplication
|
|
.TP
|
|
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:
|
|
.PP
|
|
.nf
|
|
.br
|
|
QSettings settings;
|
|
.br
|
|
settings.insertSearchPath( QSettings::Unix, "/opt/MyCompany/share/etc" );
|
|
.br
|
|
settings.insertSearchPath( QSettings::Unix, "/opt/MyCompany/share/MyApplication/etc" );
|
|
.br
|
|
// ...
|
|
.br
|
|
.fi
|
|
Will result in a search path of: <ol type=1>
|
|
.TP
|
|
SYSCONF
|
|
.TP
|
|
/opt/MyCompany/share/etc
|
|
.TP
|
|
/opt/MyCompany/share/MyApplication/etc
|
|
.TP
|
|
$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 QSettings works in the order shown above, writing to the first settings file for which the user has write permission.
|
|
.PP
|
|
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).
|
|
.PP
|
|
See also removeSearchPath().
|
|
.PP
|
|
Example: chart/chartform.cpp.
|
|
.SH "bool QSettings::readBoolEntry ( const QString & key, bool def = FALSE, bool * ok = 0 ) const"
|
|
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().
|
|
.SH "double QSettings::readDoubleEntry ( const QString & key, double def = 0, bool * ok = 0 ) const"
|
|
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().
|
|
.SH "QString QSettings::readEntry ( const QString & key, const QString & def = QString::null, bool * ok = 0 ) const"
|
|
Reads the entry specified by \fIkey\fR, and returns a QString, 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 readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), writeEntry(), and removeEntry().
|
|
.SH "QStringList QSettings::readListEntry ( const QString & key, bool * ok = 0 ) const"
|
|
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.
|
|
.PP
|
|
.nf
|
|
.br
|
|
QStringList list = mySettings.readListEntry( "recentfiles" );
|
|
.br
|
|
QStringList::Iterator it = list.begin();
|
|
.br
|
|
while( it != list.end() ) {
|
|
.br
|
|
myProcessing( *it );
|
|
.br
|
|
++it;
|
|
.br
|
|
}
|
|
.br
|
|
.fi
|
|
.PP
|
|
See also readEntry(), readDoubleEntry(), readBoolEntry(), writeEntry(), removeEntry(), and QStringList::split().
|
|
.SH "QStringList QSettings::readListEntry ( const QString & key, const QChar & separator, bool * ok = 0 ) const"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.PP
|
|
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
|
|
.PP
|
|
Reads the entry specified by \fIkey\fR as a string. The \fIseparator\fR is used to create a QStringList by calling QStringList::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.
|
|
.PP
|
|
\fBWarning:\fR As the documentation states, QStringList::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.
|
|
.PP
|
|
Note that if you want to iterate over the list, you should iterate over a copy, e.g.
|
|
.PP
|
|
.nf
|
|
.br
|
|
QStringList list = mySettings.readListEntry( "size", " " );
|
|
.br
|
|
QStringList::Iterator it = list.begin();
|
|
.br
|
|
while( it != list.end() ) {
|
|
.br
|
|
myProcessing( *it );
|
|
.br
|
|
++it;
|
|
.br
|
|
}
|
|
.br
|
|
.fi
|
|
.PP
|
|
See also readEntry(), readDoubleEntry(), readBoolEntry(), writeEntry(), removeEntry(), and QStringList::split().
|
|
.SH "int QSettings::readNumEntry ( const QString & key, int def = 0, bool * ok = 0 ) const"
|
|
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().
|
|
.SH "bool QSettings::removeEntry ( const QString & key )"
|
|
Removes the entry specified by \fIkey\fR.
|
|
.PP
|
|
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.
|
|
.PP
|
|
See also readEntry() and writeEntry().
|
|
.SH "void QSettings::removeSearchPath ( System s, const QString & path )"
|
|
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.
|
|
.PP
|
|
See also insertSearchPath().
|
|
.SH "void QSettings::resetGroup ()"
|
|
Set the current key prefix to the empty string.
|
|
.SH "void QSettings::setPath ( const QString & domain, const QString & product, Scope scope = Global )"
|
|
Insert platform-dependent paths from platform-independent information.
|
|
.PP
|
|
The \fIdomain\fR should be an Internet domain name controlled by the producer of the software, eg. Trolltech products use "trolltech.com".
|
|
.PP
|
|
The \fIproduct\fR should be the official name of the product.
|
|
.PP
|
|
The \fIscope\fR should be QSettings::User for user-specific settings, or QSettings::Global for system-wide settings (generally these will be read-only to many users).
|
|
.PP
|
|
Not all information is relevant on all systems.
|
|
.SH "QStringList QSettings::subkeyList ( const QString & key ) const"
|
|
Returns a list of the keys which contain subkeys under \fIkey\fR. Does \fInot\fR return any keys that contain entries.
|
|
.PP
|
|
Example settings:
|
|
.PP
|
|
.nf
|
|
.br
|
|
/MyCompany/MyApplication/background color
|
|
.br
|
|
/MyCompany/MyApplication/foreground color
|
|
.br
|
|
/MyCompany/MyApplication/geometry/x
|
|
.br
|
|
/MyCompany/MyApplication/geometry/y
|
|
.br
|
|
/MyCompany/MyApplication/geometry/width
|
|
.br
|
|
/MyCompany/MyApplication/geometry/height
|
|
.br
|
|
/MyCompany/MyApplication/recent files/1
|
|
.br
|
|
/MyCompany/MyApplication/recent files/2
|
|
.br
|
|
/MyCompany/MyApplication/recent files/3
|
|
.br
|
|
.fi
|
|
.PP
|
|
.nf
|
|
.br
|
|
QStringList keys = settings.subkeyList( "/MyCompany/MyApplication" );
|
|
.br
|
|
.fi
|
|
.PP
|
|
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.
|
|
.PP
|
|
\fBWarning:\fR In the above example, if QSettings is writing to an Ini file, then a call to
|
|
.PP
|
|
.nf
|
|
.br
|
|
subkeyList("/MyCompany")
|
|
.fi
|
|
will return an empty list. This happens because a key like
|
|
.PP
|
|
.nf
|
|
.br
|
|
/MyCompany/MyApplication/background color
|
|
.fi
|
|
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 QSettings. This is a known issue which will be fixed in Qt-4.
|
|
.PP
|
|
See also entryList().
|
|
.SH "bool QSettings::writeEntry ( const QString & key, bool value )"
|
|
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.
|
|
.PP
|
|
\fBWarning:\fR On certain platforms, keys are required to contain at least two components (e.g., "/foo/bar"). This limitation does not apply to TQt 4.
|
|
.PP
|
|
See also readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), and removeEntry().
|
|
.PP
|
|
Example: chart/chartform.cpp.
|
|
.SH "bool QSettings::writeEntry ( const QString & key, double value )"
|
|
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().
|
|
.SH "bool QSettings::writeEntry ( const QString & key, int value )"
|
|
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().
|
|
.SH "bool QSettings::writeEntry ( const QString & key, const QString & value )"
|
|
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().
|
|
.SH "bool QSettings::writeEntry ( const QString & key, const QStringList & value )"
|
|
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().
|
|
.SH "bool QSettings::writeEntry ( const QString & key, const QStringList & value, const QChar & separator )"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.PP
|
|
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
|
|
.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. The list is stored as a sequence of strings separated by \fIseparator\fR (using QStringList::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.
|
|
.PP
|
|
\fBWarning:\fR The list should not contain empty or null strings, as readListEntry() will use QStringList::split() to recreate the list. As the documentation states, QStringList::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.
|
|
.PP
|
|
If an error occurs the settings are left unchanged and FALSE is returned; otherwise returns TRUE.
|
|
.PP
|
|
See also readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry(), and QStringList::join().
|
|
|
|
.SH "SEE ALSO"
|
|
.BR http://doc.trolltech.com/ntqsettings.html
|
|
.BR http://www.trolltech.com/faq/tech.html
|
|
.SH COPYRIGHT
|
|
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
|
|
license file included in the distribution for a complete license
|
|
statement.
|
|
.SH AUTHOR
|
|
Generated automatically from the source code.
|
|
.SH BUGS
|
|
If you find a bug in Qt, please report it as described in
|
|
.BR http://doc.trolltech.com/bughowto.html .
|
|
Good bug reports help us to help you. Thank you.
|
|
.P
|
|
The definitive TQt documentation is provided in HTML format; it is
|
|
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
|
|
a web browser. This man page is provided as a convenience for those
|
|
users who prefer man pages, although this format is not officially
|
|
supported by Trolltech.
|
|
.P
|
|
If you find errors in this manual page, please report them to
|
|
.BR qt-bugs@trolltech.com .
|
|
Please include the name of the manual page (tqsettings.3qt) and the Qt
|
|
version (3.3.8).
|