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.
tqt3/doc/html/ntqsettings.html

627 lines
36 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/tools/qsettings.cpp:67 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQSettings Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQSettings Class Reference</h1>
<p>The TQSettings class provides persistent platform-independent application settings.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qsettings-h.html">ntqsettings.h</a>&gt;</tt>
<p><a href="qsettings-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn>enum <a href="#Format-enum"><b>Format</b></a> { Native = 0, Ini }</li>
<li class=fn>enum <a href="#System-enum"><b>System</b></a> { Unix = 0, Windows, Mac }</li>
<li class=fn>enum <a href="#Scope-enum"><b>Scope</b></a> { User, Global }</li>
<li class=fn><a href="#TQSettings"><b>TQSettings</b></a> ()</li>
<li class=fn><a href="#TQSettings-2"><b>TQSettings</b></a> ( Format&nbsp;format )</li>
<li class=fn><a href="#~TQSettings"><b>~TQSettings</b></a> ()</li>
<li class=fn>bool <a href="#writeEntry"><b>writeEntry</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;key, bool&nbsp;value )</li>
<li class=fn>bool <a href="#writeEntry-2"><b>writeEntry</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;key, double&nbsp;value )</li>
<li class=fn>bool <a href="#writeEntry-3"><b>writeEntry</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;key, int&nbsp;value )</li>
<li class=fn>bool <a href="#writeEntry-5"><b>writeEntry</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;key, const&nbsp;TQString&nbsp;&amp;&nbsp;value )</li>
<li class=fn>bool <a href="#writeEntry-6"><b>writeEntry</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;key, const&nbsp;TQStringList&nbsp;&amp;&nbsp;value )</li>
<li class=fn>bool writeEntry ( const&nbsp;TQString&nbsp;&amp;&nbsp;key, const&nbsp;TQStringList&nbsp;&amp;&nbsp;value, const&nbsp;TQChar&nbsp;&amp;&nbsp;separator ) &nbsp;<em>(obsolete)</em></li>
<li class=fn>TQStringList <a href="#entryList"><b>entryList</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;key ) const</li>
<li class=fn>TQStringList <a href="#subkeyList"><b>subkeyList</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;key ) const</li>
<li class=fn>TQStringList <a href="#readListEntry"><b>readListEntry</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;key, bool&nbsp;*&nbsp;ok = 0 ) const</li>
<li class=fn>TQStringList readListEntry ( const&nbsp;TQString&nbsp;&amp;&nbsp;key, const&nbsp;TQChar&nbsp;&amp;&nbsp;separator, bool&nbsp;*&nbsp;ok = 0 ) const &nbsp;<em>(obsolete)</em></li>
<li class=fn>TQString <a href="#readEntry"><b>readEntry</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;key, const&nbsp;TQString&nbsp;&amp;&nbsp;def = TQString::null, bool&nbsp;*&nbsp;ok = 0 ) const</li>
<li class=fn>int <a href="#readNumEntry"><b>readNumEntry</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;key, int&nbsp;def = 0, bool&nbsp;*&nbsp;ok = 0 ) const</li>
<li class=fn>double <a href="#readDoubleEntry"><b>readDoubleEntry</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;key, double&nbsp;def = 0, bool&nbsp;*&nbsp;ok = 0 ) const</li>
<li class=fn>bool <a href="#readBoolEntry"><b>readBoolEntry</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;key, bool&nbsp;def = FALSE, bool&nbsp;*&nbsp;ok = 0 ) const</li>
<li class=fn>bool <a href="#removeEntry"><b>removeEntry</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;key )</li>
<li class=fn>void <a href="#insertSearchPath"><b>insertSearchPath</b></a> ( System&nbsp;s, const&nbsp;TQString&nbsp;&amp;&nbsp;path )</li>
<li class=fn>void <a href="#removeSearchPath"><b>removeSearchPath</b></a> ( System&nbsp;s, const&nbsp;TQString&nbsp;&amp;&nbsp;path )</li>
<li class=fn>void <a href="#setPath"><b>setPath</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;domain, const&nbsp;TQString&nbsp;&amp;&nbsp;product, Scope&nbsp;scope = Global )</li>
<li class=fn>void <a href="#beginGroup"><b>beginGroup</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;group )</li>
<li class=fn>void <a href="#endGroup"><b>endGroup</b></a> ()</li>
<li class=fn>void <a href="#resetGroup"><b>resetGroup</b></a> ()</li>
<li class=fn>TQString <a href="#group"><b>group</b></a> () const</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The TQSettings class provides persistent platform-independent application settings.
<p>
<p> 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.
<p> Each setting comprises an identifying key and the data associated with
the key. A key is a unicode string which consists of <em>two</em> 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.
<p> 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 <a href="ntqsessionmanager.html">TQSessionManager</a> to save the
desktop's session.
<p> Example settings:
<pre>
/MyCompany/MyApplication/background color
/MyCompany/MyApplication/foreground color
/MyCompany/MyApplication/geometry/x
/MyCompany/MyApplication/geometry/y
/MyCompany/MyApplication/geometry/width
/MyCompany/MyApplication/geometry/height
/MyCompany/MyApplication/recent files/1
/MyCompany/MyApplication/recent files/2
/MyCompany/MyApplication/recent files/3
</pre>
Each line above is a complete key, made up of subkeys.
<p> A typical usage pattern for reading settings at application
startup:
<pre>
TQSettings settings;
settings.<a href="#setPath">setPath</a>( "MyCompany.com", "MyApplication" );
<a href="ntqstring.html">TQString</a> bgColor = settings.<a href="#readEntry">readEntry</a>( "/colors/background", "white" );
int width = settings.<a href="#readNumEntry">readNumEntry</a>( "/geometry/width", 640 );
// ...
</pre>
<p> A typical usage pattern for saving settings at application exit or
'save preferences':
<pre>
TQSettings settings;
settings.<a href="#setPath">setPath</a>( "MyCompany.com", "MyApplication" );
settings.<a href="#writeEntry">writeEntry</a>( "/colors/background", bgColor );
settings.<a href="#writeEntry">writeEntry</a>( "/geometry/width", width );
// ...
</pre>
<p> A key prefix can be prepended to all keys using <a href="#beginGroup">beginGroup</a>(). The
application of the prefix is stopped using <a href="#endGroup">endGroup</a>(). For
example:
<pre>
TQSettings settings;
settings.<a href="#beginGroup">beginGroup</a>( "/MainWindow" );
settings.<a href="#beginGroup">beginGroup</a>( "/Geometry" );
int x = settings.<a href="#readEntry">readEntry</a>( "/x" );
// ...
settings.<a href="#endGroup">endGroup</a>();
settings.<a href="#beginGroup">beginGroup</a>( "/Toolbars" );
// ...
settings.<a href="#endGroup">endGroup</a>();
settings.<a href="#endGroup">endGroup</a>();
</pre>
<p> You can get a list of entry-holding keys by calling <a href="#entryList">entryList</a>(), and
a list of key-holding keys using <a href="#subkeyList">subkeyList</a>().
<p> <pre>
<a href="ntqstringlist.html">TQStringList</a> keys = settings.entryList( "/MyApplication" );
// keys contains 'background color' and 'foreground color'.
<a href="ntqstringlist.html">TQStringList</a> keys = settings.entryList( "/MyApplication/recent files" );
// keys contains '1', '2' and '3'.
<a href="ntqstringlist.html">TQStringList</a> subkeys = settings.subkeyList( "/MyApplication" );
// subkeys contains 'geometry' and 'recent files'
<a href="ntqstringlist.html">TQStringList</a> subkeys = settings.subkeyList( "/MyApplication/recent files" );
// subkeys is empty.
</pre>
<p> Since settings for Windows are stored in the registry there are
some size limitations as follows:
<ul>
<li> A subkey may not exceed 255 characters.
<li> An entry's value may not exceed 16,300 characters.
<li> All the values of a key (for example, all the 'recent files'
subkeys values), may not exceed 65,535 characters.
</ul>
<p> These limitations are not enforced on Unix or Mac OS X.
<p> <b>Warning:</b> 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 TQt.
<p> <h3> Notes for Mac OS X Applications
</h3>
<a name="1"></a><p> The location where settings are stored is not formally defined by
the CFPreferences API.
<p> At the time of writing settings are stored (either on a global or
user basis, preferring locally) into a plist file in <tt>$ROOT/System/Library/Preferences</tt> (in XML format). TQSettings will
create an appropriate plist file (<tt>com.&lt;first group name&gt;.plist</tt>)
out of the full path to a key.
<p> For further information on CFPreferences see
<a href="http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFPreferences/index.html">Apple's Specifications</a>
<p> <h3> Notes for Unix Applications
</h3>
<a name="1-1"></a><p> 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>
<li> <tt>SYSCONF</tt> - the default value is <tt>INSTALL/etc/settings</tt>
<li> <tt>/opt/MyCompany/share/etc</tt>
<li> <tt>/opt/MyCompany/share/MyApplication/etc</tt>
<li> <tt>$HOME/.qt</tt>
</ol>
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.
(<tt>INSTALL</tt> is the directory where TQt was installed. This can be
modified by using the configure script's -prefix argument )
<p> If you want to put the settings in a particular place in the
filesystem you could do this:
<pre>
settings.insertSearchPath( TQSettings::<a href="#System-enum">Unix</a>, "/opt/MyCompany/share" );
</pre>
<p> But in practice you may prefer not to use a search path for Unix.
For example the following code:
<pre>
settings.writeEntry( "/MyApplication/geometry/width", width );
</pre>
will end up writing the "geometry/width" setting to the file
<tt>$HOME/.qt/myapplicationrc</tt> (assuming that the application is
being run by an ordinary user, i.e. not by root).
<p> For cross-platform applications you should ensure that the
<a href="#sizelimit">Windows size limitations</a> are not exceeded.
<p> <b>Warning:</b> TQSettings doesn't write the settings until it is destroyed so
you should construct the TQSettings object on the stack.
<p>See also <a href="io.html">Input/Output and Networking</a> and <a href="misc.html">Miscellaneous Classes</a>.
<hr><h2>Member Type Documentation</h2>
<h3 class=fn><a name="Format-enum"></a>TQSettings::Format</h3>
<ul>
<li><tt>TQSettings::Native</tt> - Store the settings in a platform dependent location
<li><tt>TQSettings::Ini</tt> - Store the settings in a text file
</ul>
<h3 class=fn><a name="Scope-enum"></a>TQSettings::Scope</h3>
<ul>
<li><tt>TQSettings::Global</tt> - Save settings as global as possible
<li><tt>TQSettings::User</tt> - Save settings in user space
</ul>
<h3 class=fn><a name="System-enum"></a>TQSettings::System</h3>
<ul>
<li><tt>TQSettings::Mac</tt> - Macintosh execution environments
<li><tt>TQSettings::Unix</tt> - Mac OS X, Unix, Linux and Unix-like execution environments
<li><tt>TQSettings::Windows</tt> - Windows execution environments
</ul>
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="TQSettings"></a>TQSettings::TQSettings ()
</h3>
Creates a settings object.
<p> Be aware that you must call <a href="#setPath">setPath</a>() or <a href="#insertSearchPath">insertSearchPath</a>() before
you can use the TQSettings object.
<h3 class=fn><a name="TQSettings-2"></a>TQSettings::TQSettings ( <a href="ntqsettings.html#Format-enum">Format</a>&nbsp;format )
</h3>
Creates a settings object. If <em>format</em> is 'Ini' the settings will
be stored in a text file, using the Unix strategy (see above). If <em>format</em>
is 'Native', the settings will be stored in a platform specific way
(ie. the Windows registry).
<p> Be aware that you must call <a href="#setPath">setPath</a>() or <a href="#insertSearchPath">insertSearchPath</a>() before
you can use the TQSettings object.
<h3 class=fn><a name="~TQSettings"></a>TQSettings::~TQSettings ()
</h3>
Destroys the settings object. All modifications made to the settings
will automatically be saved.
<p>
<h3 class=fn>void <a name="beginGroup"></a>TQSettings::beginGroup ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;group )
</h3>
Appends <em>group</em> to the current key prefix.
<p> <pre>
TQSettings settings;
settings.<a href="#beginGroup">beginGroup</a>( "/MainWindow" );
// read values
settings.<a href="#endGroup">endGroup</a>();
</pre>
<h3 class=fn>void <a name="endGroup"></a>TQSettings::endGroup ()
</h3>
Undo previous calls to <a href="#beginGroup">beginGroup</a>(). Note that a single beginGroup("a/b/c") is undone
by a single call to <a href="#endGroup">endGroup</a>().
<p> <pre>
TQSettings settings;
settings.<a href="#beginGroup">beginGroup</a>( "/MainWindow/Geometry" );
// read values
settings.<a href="#endGroup">endGroup</a>();
</pre>
<h3 class=fn><a href="ntqstringlist.html">TQStringList</a> <a name="entryList"></a>TQSettings::entryList ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;key ) const
</h3>
Returns a list of the keys which contain entries under <em>key</em>. Does <em>not</em> return any keys that contain subkeys.
<p> Example settings:
<pre>
/MyCompany/MyApplication/background color
/MyCompany/MyApplication/foreground color
/MyCompany/MyApplication/geometry/x
/MyCompany/MyApplication/geometry/y
/MyCompany/MyApplication/geometry/width
/MyCompany/MyApplication/geometry/height
</pre>
<pre>
<a href="ntqstringlist.html">TQStringList</a> keys = settings.entryList( "/MyCompany/MyApplication" );
</pre>
<p> In the above example, <tt>keys</tt> will contain 'background color' and
'foreground color'. It will not contain 'geometry' because this key
contains subkeys not entries.
<p> To access the geometry values, you could either use <a href="#subkeyList">subkeyList</a>()
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".
<p> <p>See also <a href="#subkeyList">subkeyList</a>().
<h3 class=fn><a href="ntqstring.html">TQString</a> <a name="group"></a>TQSettings::group () const
</h3>
Returns the current key prefix, or a null string if there is no key prefix set.
<p> <p>See also <a href="#beginGroup">beginGroup</a>().
<h3 class=fn>void <a name="insertSearchPath"></a>TQSettings::insertSearchPath ( <a href="ntqsettings.html#System-enum">System</a>&nbsp;s, const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;path )
</h3>
Inserts <em>path</em> into the settings search path. The semantics of <em>path</em> depends on the system <em>s</em>. It is usually easier and better to
use <a href="#setPath">setPath</a>() instead of this function.
<p> When <em>s</em> is <em>Windows</em> and the execution environment is <em>not</em>
Windows the function does nothing. Similarly when <em>s</em> is <em>Unix</em> and
the execution environment is <em>not</em> Unix the function does nothing.
<p> When <em>s</em> is <em>Windows</em>, and the execution environment is Windows, the
search path list will be used as the first subfolder of the "Software"
folder in the registry.
<p> 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>
<li> HKEY_CURRENT_USER/Software/MyCompany/MyApplication
<li> HKEY_LOCAL_MACHINE/Software/MyCompany/MyApplication
<li> HKEY_CURRENT_USER/Software/MyApplication
<li> HKEY_LOCAL_MACHINE/Software/MyApplication
</ol>
<p> <pre>
TQSettings settings;
settings.<a href="#insertSearchPath">insertSearchPath</a>( TQSettings::<a href="#System-enum">Windows</a>, "/MyCompany" );
settings.<a href="#writeEntry">writeEntry</a>( "/MyApplication/Tip of the day", TRUE );
</pre>
The code above will write the subkey "Tip of the day" into the <em>first</em> of the registry folders listed below that is found and for
which the user has write permission.
<ol type=1>
<li> HKEY_LOCAL_MACHINE/Software/MyCompany/MyApplication
<li> HKEY_CURRENT_USER/Software/MyCompany/MyApplication
<li> HKEY_LOCAL_MACHINE/Software/MyApplication
<li> HKEY_CURRENT_USER/Software/MyApplication
</ol>
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.
<p> When <em>s</em> is <em>Unix</em>, 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:
<p> <ol type=1>
<li> <tt>SYSCONF</tt> - where <tt>SYSCONF</tt> is a directory specified when
configuring TQt; by default it is INSTALL/etc/settings.
<li> <tt>$HOME/.qt/</tt> - where <tt>$HOME</tt> is the user's home directory.
</ol>
<p> All insertions into the search path will go before $HOME/.qt/.
For example:
<pre>
TQSettings settings;
settings.<a href="#insertSearchPath">insertSearchPath</a>( TQSettings::<a href="#System-enum">Unix</a>, "/opt/MyCompany/share/etc" );
settings.<a href="#insertSearchPath">insertSearchPath</a>( TQSettings::<a href="#System-enum">Unix</a>, "/opt/MyCompany/share/MyApplication/etc" );
// ...
</pre>
Will result in a search path of:
<ol type=1>
<li> SYSCONF
<li> /opt/MyCompany/share/etc
<li> /opt/MyCompany/share/MyApplication/etc
<li> $HOME/.qt
</ol>
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.
<p> Note that paths in the file system are not created by this
function, so they must already exist to be useful.
<p> 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.
<tt>/MyCompany/MyApplication/background color</tt> will be stored in
<tt>myapplicationrc</tt> (assuming that <tt>/MyCompany</tt> is part of
the search path).
<p> <p>See also <a href="#removeSearchPath">removeSearchPath</a>().
<p>
<p>Example: <a href="canvas-chart-example.html#x2890">chart/chartform.cpp</a>.
<h3 class=fn>bool <a name="readBoolEntry"></a>TQSettings::readBoolEntry ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;key, bool&nbsp;def = FALSE, bool&nbsp;*&nbsp;ok = 0 ) const
</h3>
<p> Reads the entry specified by <em>key</em>, and returns a bool, or the
default value, <em>def</em>, if the entry couldn't be read.
If <em>ok</em> is non-null, *ok is set to TRUE if the key was read, FALSE
otherwise.
<p> <p>See also <a href="#readEntry">readEntry</a>(), <a href="#readNumEntry">readNumEntry</a>(), <a href="#readDoubleEntry">readDoubleEntry</a>(), <a href="#writeEntry">writeEntry</a>(), and <a href="#removeEntry">removeEntry</a>().
<h3 class=fn>double <a name="readDoubleEntry"></a>TQSettings::readDoubleEntry ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;key, double&nbsp;def = 0, bool&nbsp;*&nbsp;ok = 0 ) const
</h3>
<p> Reads the entry specified by <em>key</em>, and returns a double, or the
default value, <em>def</em>, if the entry couldn't be read.
If <em>ok</em> is non-null, *ok is set to TRUE if the key was read, FALSE
otherwise.
<p> <p>See also <a href="#readEntry">readEntry</a>(), <a href="#readNumEntry">readNumEntry</a>(), <a href="#readBoolEntry">readBoolEntry</a>(), <a href="#writeEntry">writeEntry</a>(), and <a href="#removeEntry">removeEntry</a>().
<h3 class=fn><a href="ntqstring.html">TQString</a> <a name="readEntry"></a>TQSettings::readEntry ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;key, const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;def = TQString::null, bool&nbsp;*&nbsp;ok = 0 ) const
</h3>
<p> Reads the entry specified by <em>key</em>, and returns a <a href="ntqstring.html">TQString</a>, or the
default value, <em>def</em>, if the entry couldn't be read.
If <em>ok</em> is non-null, *ok is set to TRUE if the key was read, FALSE
otherwise.
<p> <p>See also <a href="#readListEntry">readListEntry</a>(), <a href="#readNumEntry">readNumEntry</a>(), <a href="#readDoubleEntry">readDoubleEntry</a>(), <a href="#readBoolEntry">readBoolEntry</a>(), <a href="#writeEntry">writeEntry</a>(), and <a href="#removeEntry">removeEntry</a>().
<h3 class=fn><a href="ntqstringlist.html">TQStringList</a> <a name="readListEntry"></a>TQSettings::readListEntry ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;key, bool&nbsp;*&nbsp;ok = 0 ) const
</h3>
Reads the entry specified by <em>key</em> as a string. If <em>ok</em> is not
0, <em>*ok</em> is set to TRUE if the key was read, otherwise <em>*ok</em> is
set to FALSE.
<p> Note that if you want to iterate over the list, you should iterate
over a copy, e.g.
<pre>
<a href="ntqstringlist.html">TQStringList</a> list = mySettings.readListEntry( "recentfiles" );
TQStringList::Iterator it = list.<a href="ntqvaluelist.html#begin">begin</a>();
while( it != list.<a href="ntqvaluelist.html#end">end</a>() ) {
myProcessing( *it );
++it;
}
</pre>
<p> <p>See also <a href="#readEntry">readEntry</a>(), <a href="#readDoubleEntry">readDoubleEntry</a>(), <a href="#readBoolEntry">readBoolEntry</a>(), <a href="#writeEntry">writeEntry</a>(), <a href="#removeEntry">removeEntry</a>(), and <a href="ntqstringlist.html#split">TQStringList::split</a>().
<h3 class=fn><a href="ntqstringlist.html">TQStringList</a> <a name="readListEntry-4"></a>TQSettings::readListEntry ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;key, const&nbsp;<a href="qchar.html">TQChar</a>&nbsp;&amp;&nbsp;separator, bool&nbsp;*&nbsp;ok = 0 ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> Reads the entry specified by <em>key</em> as a string. The <em>separator</em>
is used to create a <a href="ntqstringlist.html">TQStringList</a> by calling <a href="ntqstringlist.html#split">TQStringList::split</a>(<em>separator</em>, entry). If <em>ok</em> is not 0: <em>*ok</em> is set to TRUE
if the key was read, otherwise <em>*ok</em> is set to FALSE.
<p> <b>Warning:</b> 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 <a href="#readListEntry">readListEntry</a>() and <a href="#writeEntry">writeEntry</a>() overloads
that do not take a <em>separator</em> argument.
<p> Note that if you want to iterate over the list, you should iterate
over a copy, e.g.
<pre>
<a href="ntqstringlist.html">TQStringList</a> list = mySettings.readListEntry( "size", " " );
TQStringList::Iterator it = list.<a href="ntqvaluelist.html#begin">begin</a>();
while( it != list.<a href="ntqvaluelist.html#end">end</a>() ) {
myProcessing( *it );
++it;
}
</pre>
<p> <p>See also <a href="#readEntry">readEntry</a>(), <a href="#readDoubleEntry">readDoubleEntry</a>(), <a href="#readBoolEntry">readBoolEntry</a>(), <a href="#writeEntry">writeEntry</a>(), <a href="#removeEntry">removeEntry</a>(), and <a href="ntqstringlist.html#split">TQStringList::split</a>().
<h3 class=fn>int <a name="readNumEntry"></a>TQSettings::readNumEntry ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;key, int&nbsp;def = 0, bool&nbsp;*&nbsp;ok = 0 ) const
</h3>
<p> Reads the entry specified by <em>key</em>, and returns an integer, or the
default value, <em>def</em>, if the entry couldn't be read.
If <em>ok</em> is non-null, *ok is set to TRUE if the key was read, FALSE
otherwise.
<p> <p>See also <a href="#readEntry">readEntry</a>(), <a href="#readDoubleEntry">readDoubleEntry</a>(), <a href="#readBoolEntry">readBoolEntry</a>(), <a href="#writeEntry">writeEntry</a>(), and <a href="#removeEntry">removeEntry</a>().
<h3 class=fn>bool <a name="removeEntry"></a>TQSettings::removeEntry ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;key )
</h3>
Removes the entry specified by <em>key</em>.
<p> 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.
<p> <p>See also <a href="#readEntry">readEntry</a>() and <a href="#writeEntry">writeEntry</a>().
<h3 class=fn>void <a name="removeSearchPath"></a>TQSettings::removeSearchPath ( <a href="ntqsettings.html#System-enum">System</a>&nbsp;s, const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;path )
</h3>
Removes all occurrences of <em>path</em> (using exact matching) from the
settings search path for system <em>s</em>. Note that the default search
paths cannot be removed.
<p> <p>See also <a href="#insertSearchPath">insertSearchPath</a>().
<h3 class=fn>void <a name="resetGroup"></a>TQSettings::resetGroup ()
</h3>
Set the current key prefix to the empty string.
<h3 class=fn>void <a name="setPath"></a>TQSettings::setPath ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;domain, const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;product, <a href="ntqsettings.html#Scope-enum">Scope</a>&nbsp;scope = Global )
</h3>
Insert platform-dependent paths from platform-independent information.
<p> The <em>domain</em> should be an Internet domain name
controlled by the producer of the software, eg. Trolltech products
use "trolltech.com".
<p> The <em>product</em> should be the official name of the product.
<p> The <em>scope</em> should be
TQSettings::User for user-specific settings, or
TQSettings::Global for system-wide settings (generally
these will be read-only to many users).
<p> Not all information is relevant on all systems.
<h3 class=fn><a href="ntqstringlist.html">TQStringList</a> <a name="subkeyList"></a>TQSettings::subkeyList ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;key ) const
</h3>
Returns a list of the keys which contain subkeys under <em>key</em>. Does <em>not</em> return any keys that contain entries.
<p> Example settings:
<pre>
/MyCompany/MyApplication/background color
/MyCompany/MyApplication/foreground color
/MyCompany/MyApplication/geometry/x
/MyCompany/MyApplication/geometry/y
/MyCompany/MyApplication/geometry/width
/MyCompany/MyApplication/geometry/height
/MyCompany/MyApplication/recent files/1
/MyCompany/MyApplication/recent files/2
/MyCompany/MyApplication/recent files/3
</pre>
<pre>
<a href="ntqstringlist.html">TQStringList</a> keys = settings.subkeyList( "/MyCompany/MyApplication" );
</pre>
<p> In the above example, <tt>keys</tt> 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 <a href="#entryList">entryList</a>() instead.
<p> <b>Warning:</b> In the above example, if TQSettings is writing to an Ini file,
then a call to
<pre> subkeyList("/MyCompany") </pre>
will return an empty list. This happens because a key like
<pre> /MyCompany/MyApplication/background color </pre>
is written to the file <em>"mycompanyrc"</em>, under the section <em>[MyApplication]</em>.
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 TQt-4.
<p> <p>See also <a href="#entryList">entryList</a>().
<h3 class=fn>bool <a name="writeEntry"></a>TQSettings::writeEntry ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;key, bool&nbsp;value )
</h3>
Writes the boolean entry <em>value</em> into key <em>key</em>. The <em>key</em> is
created if it doesn't exist. Any previous value is overwritten by <em>value</em>.
<p> If an error occurs the settings are left unchanged and FALSE is
returned; otherwise TRUE is returned.
<p> <b>Warning:</b> On certain platforms, keys are required to contain at least
two components (e.g., "/foo/bar"). This limitation does not apply to
TQt 4.
<p> <p>See also <a href="#readListEntry">readListEntry</a>(), <a href="#readNumEntry">readNumEntry</a>(), <a href="#readDoubleEntry">readDoubleEntry</a>(), <a href="#readBoolEntry">readBoolEntry</a>(), and <a href="#removeEntry">removeEntry</a>().
<p>Example: <a href="canvas-chart-example.html#x2891">chart/chartform.cpp</a>.
<h3 class=fn>bool <a name="writeEntry-2"></a>TQSettings::writeEntry ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;key, double&nbsp;value )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Writes the double entry <em>value</em> into key <em>key</em>. The <em>key</em> is
created if it doesn't exist. Any previous value is overwritten by <em>value</em>.
<p> If an error occurs the settings are left unchanged and FALSE is
returned; otherwise TRUE is returned.
<p> <p>See also <a href="#readListEntry">readListEntry</a>(), <a href="#readNumEntry">readNumEntry</a>(), <a href="#readDoubleEntry">readDoubleEntry</a>(), <a href="#readBoolEntry">readBoolEntry</a>(), and <a href="#removeEntry">removeEntry</a>().
<h3 class=fn>bool <a name="writeEntry-3"></a>TQSettings::writeEntry ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;key, int&nbsp;value )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Writes the integer entry <em>value</em> into key <em>key</em>. The <em>key</em> is
created if it doesn't exist. Any previous value is overwritten by <em>value</em>.
<p> If an error occurs the settings are left unchanged and FALSE is
returned; otherwise TRUE is returned.
<p> <p>See also <a href="#readListEntry">readListEntry</a>(), <a href="#readNumEntry">readNumEntry</a>(), <a href="#readDoubleEntry">readDoubleEntry</a>(), <a href="#readBoolEntry">readBoolEntry</a>(), and <a href="#removeEntry">removeEntry</a>().
<h3 class=fn>bool <a name="writeEntry-5"></a>TQSettings::writeEntry ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;key, const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;value )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Writes the string entry <em>value</em> into key <em>key</em>. The <em>key</em> is
created if it doesn't exist. Any previous value is overwritten by <em>value</em>. If <em>value</em> is an empty string or a null string the key's
value will be an empty string.
<p> If an error occurs the settings are left unchanged and FALSE is
returned; otherwise TRUE is returned.
<p> <p>See also <a href="#readListEntry">readListEntry</a>(), <a href="#readNumEntry">readNumEntry</a>(), <a href="#readDoubleEntry">readDoubleEntry</a>(), <a href="#readBoolEntry">readBoolEntry</a>(), and <a href="#removeEntry">removeEntry</a>().
<h3 class=fn>bool <a name="writeEntry-6"></a>TQSettings::writeEntry ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;key, const&nbsp;<a href="ntqstringlist.html">TQStringList</a>&nbsp;&amp;&nbsp;value )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Writes the string list entry <em>value</em> into key <em>key</em>. The <em>key</em>
is created if it doesn't exist. Any previous value is overwritten
by <em>value</em>.
<p> If an error occurs the settings are left unchanged and FALSE is
returned; otherwise returns TRUE.
<p> <p>See also <a href="#readListEntry">readListEntry</a>(), <a href="#readNumEntry">readNumEntry</a>(), <a href="#readDoubleEntry">readDoubleEntry</a>(), <a href="#readBoolEntry">readBoolEntry</a>(), and <a href="#removeEntry">removeEntry</a>().
<h3 class=fn>bool <a name="writeEntry-7"></a>TQSettings::writeEntry ( const&nbsp;<a href="ntqstring.html">TQString</a>&nbsp;&amp;&nbsp;key, const&nbsp;<a href="ntqstringlist.html">TQStringList</a>&nbsp;&amp;&nbsp;value, const&nbsp;<a href="qchar.html">TQChar</a>&nbsp;&amp;&nbsp;separator )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> Writes the string list entry <em>value</em> into key <em>key</em>. The <em>key</em>
is created if it doesn't exist. Any previous value is overwritten
by <em>value</em>. The list is stored as a sequence of strings separated
by <em>separator</em> (using <a href="ntqstringlist.html#join">TQStringList::join</a>()), 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.
<p> <b>Warning:</b> The list should not contain empty or null strings, as
<a href="#readListEntry">readListEntry</a>() will use <a href="ntqstringlist.html#split">TQStringList::split</a>() 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 <a href="#writeEntry">writeEntry</a>() and readListEntry() overloads
that do not take a <em>separator</em> argument.
<p> If an error occurs the settings are left unchanged and FALSE is
returned; otherwise returns TRUE.
<p> <p>See also <a href="#readListEntry">readListEntry</a>(), <a href="#readNumEntry">readNumEntry</a>(), <a href="#readDoubleEntry">readDoubleEntry</a>(), <a href="#readBoolEntry">readBoolEntry</a>(), <a href="#removeEntry">removeEntry</a>(), and <a href="ntqstringlist.html#join">TQStringList::join</a>().
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright &copy; 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>