source: trunk/doc/html/qsettings.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 36.0 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/tools/qsettings.cpp:67 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QSettings Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QSettings Class Reference</h1>
33
34<p>The QSettings class provides persistent platform-independent application settings.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qsettings-h.html">qsettings.h</a>&gt;</tt>
37<p><a href="qsettings-members.html">List of all member functions.</a>
38<h2>Public Members</h2>
39<ul>
40<li class=fn>enum <a href="#Format-enum"><b>Format</b></a> { Native = 0, Ini }</li>
41<li class=fn>enum <a href="#System-enum"><b>System</b></a> { Unix = 0, Windows, Mac }</li>
42<li class=fn>enum <a href="#Scope-enum"><b>Scope</b></a> { User, Global }</li>
43<li class=fn><a href="#QSettings"><b>QSettings</b></a> ()</li>
44<li class=fn><a href="#QSettings-2"><b>QSettings</b></a> ( Format&nbsp;format )</li>
45<li class=fn><a href="#~QSettings"><b>~QSettings</b></a> ()</li>
46<li class=fn>bool <a href="#writeEntry"><b>writeEntry</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;key, bool&nbsp;value )</li>
47<li class=fn>bool <a href="#writeEntry-2"><b>writeEntry</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;key, double&nbsp;value )</li>
48<li class=fn>bool <a href="#writeEntry-3"><b>writeEntry</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;key, int&nbsp;value )</li>
49<li class=fn>bool <a href="#writeEntry-5"><b>writeEntry</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;key, const&nbsp;QString&nbsp;&amp;&nbsp;value )</li>
50<li class=fn>bool <a href="#writeEntry-6"><b>writeEntry</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;key, const&nbsp;QStringList&nbsp;&amp;&nbsp;value )</li>
51<li class=fn>bool writeEntry ( const&nbsp;QString&nbsp;&amp;&nbsp;key, const&nbsp;QStringList&nbsp;&amp;&nbsp;value, const&nbsp;QChar&nbsp;&amp;&nbsp;separator ) &nbsp;<em>(obsolete)</em></li>
52<li class=fn>QStringList <a href="#entryList"><b>entryList</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;key ) const</li>
53<li class=fn>QStringList <a href="#subkeyList"><b>subkeyList</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;key ) const</li>
54<li class=fn>QStringList <a href="#readListEntry"><b>readListEntry</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;key, bool&nbsp;*&nbsp;ok = 0 ) const</li>
55<li class=fn>QStringList readListEntry ( const&nbsp;QString&nbsp;&amp;&nbsp;key, const&nbsp;QChar&nbsp;&amp;&nbsp;separator, bool&nbsp;*&nbsp;ok = 0 ) const &nbsp;<em>(obsolete)</em></li>
56<li class=fn>QString <a href="#readEntry"><b>readEntry</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;key, const&nbsp;QString&nbsp;&amp;&nbsp;def = QString::null, bool&nbsp;*&nbsp;ok = 0 ) const</li>
57<li class=fn>int <a href="#readNumEntry"><b>readNumEntry</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;key, int&nbsp;def = 0, bool&nbsp;*&nbsp;ok = 0 ) const</li>
58<li class=fn>double <a href="#readDoubleEntry"><b>readDoubleEntry</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;key, double&nbsp;def = 0, bool&nbsp;*&nbsp;ok = 0 ) const</li>
59<li class=fn>bool <a href="#readBoolEntry"><b>readBoolEntry</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;key, bool&nbsp;def = FALSE, bool&nbsp;*&nbsp;ok = 0 ) const</li>
60<li class=fn>bool <a href="#removeEntry"><b>removeEntry</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;key )</li>
61<li class=fn>void <a href="#insertSearchPath"><b>insertSearchPath</b></a> ( System&nbsp;s, const&nbsp;QString&nbsp;&amp;&nbsp;path )</li>
62<li class=fn>void <a href="#removeSearchPath"><b>removeSearchPath</b></a> ( System&nbsp;s, const&nbsp;QString&nbsp;&amp;&nbsp;path )</li>
63<li class=fn>void <a href="#setPath"><b>setPath</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;domain, const&nbsp;QString&nbsp;&amp;&nbsp;product, Scope&nbsp;scope = Global )</li>
64<li class=fn>void <a href="#beginGroup"><b>beginGroup</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;group )</li>
65<li class=fn>void <a href="#endGroup"><b>endGroup</b></a> ()</li>
66<li class=fn>void <a href="#resetGroup"><b>resetGroup</b></a> ()</li>
67<li class=fn>QString <a href="#group"><b>group</b></a> () const</li>
68</ul>
69<hr><a name="details"></a><h2>Detailed Description</h2>
70
71
72The QSettings class provides persistent platform-independent application settings.
73<p>
74
75
76<p> On Unix systems, QSettings uses text files to store settings. On Windows
77systems, QSettings uses the system registry. On Mac OS X, QSettings uses
78the Carbon preferences API.
79<p> Each setting comprises an identifying key and the data associated with
80the key. A key is a unicode string which consists of <em>two</em> or more
81subkeys. A subkey is a slash, '/', followed by one or more unicode
82characters (excluding slashes, newlines, carriage returns and equals,
83'=', signs). The associated data, called the entry or value, may be a
84boolean, an integer, a double, a string or a list of strings. Entry
85strings may contain any unicode characters.
86<p> If you want to save and restore the entire desktop's settings, i.e.
87which applications are running, use QSettings to save the settings
88for each individual application and <a href="qsessionmanager.html">QSessionManager</a> to save the
89desktop's session.
90<p> Example settings:
91<pre>
92 /MyCompany/MyApplication/background color
93 /MyCompany/MyApplication/foreground color
94 /MyCompany/MyApplication/geometry/x
95 /MyCompany/MyApplication/geometry/y
96 /MyCompany/MyApplication/geometry/width
97 /MyCompany/MyApplication/geometry/height
98 /MyCompany/MyApplication/recent files/1
99 /MyCompany/MyApplication/recent files/2
100 /MyCompany/MyApplication/recent files/3
101 </pre>
102
103Each line above is a complete key, made up of subkeys.
104<p> A typical usage pattern for reading settings at application
105startup:
106<pre>
107 QSettings settings;
108 settings.<a href="#setPath">setPath</a>( "MyCompany.com", "MyApplication" );
109
110 <a href="qstring.html">QString</a> bgColor = settings.<a href="#readEntry">readEntry</a>( "/colors/background", "white" );
111 int width = settings.<a href="#readNumEntry">readNumEntry</a>( "/geometry/width", 640 );
112 // ...
113 </pre>
114
115<p> A typical usage pattern for saving settings at application exit or
116'save preferences':
117<pre>
118 QSettings settings;
119 settings.<a href="#setPath">setPath</a>( "MyCompany.com", "MyApplication" );
120
121 settings.<a href="#writeEntry">writeEntry</a>( "/colors/background", bgColor );
122 settings.<a href="#writeEntry">writeEntry</a>( "/geometry/width", width );
123 // ...
124 </pre>
125
126<p> A key prefix can be prepended to all keys using <a href="#beginGroup">beginGroup</a>(). The
127application of the prefix is stopped using <a href="#endGroup">endGroup</a>(). For
128example:
129<pre>
130 QSettings settings;
131
132 settings.<a href="#beginGroup">beginGroup</a>( "/MainWindow" );
133 settings.<a href="#beginGroup">beginGroup</a>( "/Geometry" );
134 int x = settings.<a href="#readEntry">readEntry</a>( "/x" );
135 // ...
136 settings.<a href="#endGroup">endGroup</a>();
137 settings.<a href="#beginGroup">beginGroup</a>( "/Toolbars" );
138 // ...
139 settings.<a href="#endGroup">endGroup</a>();
140 settings.<a href="#endGroup">endGroup</a>();
141 </pre>
142
143<p> You can get a list of entry-holding keys by calling <a href="#entryList">entryList</a>(), and
144a list of key-holding keys using <a href="#subkeyList">subkeyList</a>().
145<p> <pre>
146 <a href="qstringlist.html">QStringList</a> keys = settings.entryList( "/MyApplication" );
147 // keys contains 'background color' and 'foreground color'.
148
149 <a href="qstringlist.html">QStringList</a> keys = settings.entryList( "/MyApplication/recent files" );
150 // keys contains '1', '2' and '3'.
151
152 <a href="qstringlist.html">QStringList</a> subkeys = settings.subkeyList( "/MyApplication" );
153 // subkeys contains 'geometry' and 'recent files'
154
155 <a href="qstringlist.html">QStringList</a> subkeys = settings.subkeyList( "/MyApplication/recent files" );
156 // subkeys is empty.
157 </pre>
158
159<p> Since settings for Windows are stored in the registry there are
160some size limitations as follows:
161<ul>
162<li> A subkey may not exceed 255 characters.
163<li> An entry's value may not exceed 16,300 characters.
164<li> All the values of a key (for example, all the 'recent files'
165subkeys values), may not exceed 65,535 characters.
166</ul>
167<p> These limitations are not enforced on Unix or Mac OS X.
168<p> <b>Warning:</b> Creating multiple, simultaneous instances of QSettings writing
169to a text file may lead to data loss! This is a known issue which will
170be fixed in a future release of Qt.
171<p> <h3> Notes for Mac OS X Applications
172</h3>
173<a name="1"></a><p> The location where settings are stored is not formally defined by
174the CFPreferences API.
175<p> At the time of writing settings are stored (either on a global or
176user basis, preferring locally) into a plist file in <tt>$ROOT/System/Library/Preferences</tt> (in XML format). QSettings will
177create an appropriate plist file (<tt>com.&lt;first group name&gt;.plist</tt>)
178out of the full path to a key.
179<p> For further information on CFPreferences see
180<a href="http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFPreferences/index.html">Apple's Specifications</a>
181<p> <h3> Notes for Unix Applications
182</h3>
183<a name="1-1"></a><p> There is no universally accepted place for storing application
184settings under Unix. In the examples the settings file will be
185searched for in the following directories:
186<ol type=1>
187<li> <tt>SYSCONF</tt> - the default value is <tt>INSTALL/etc/settings</tt>
188<li> <tt>/opt/MyCompany/share/etc</tt>
189<li> <tt>/opt/MyCompany/share/MyApplication/etc</tt>
190<li> <tt>$HOME/.qt</tt>
191</ol>
192When reading settings the files are searched in the order shown
193above, with later settings overriding earlier settings. Files for
194which the user doesn't have read permission are ignored. When saving
195settings QSettings works in the order shown above, writing
196to the first settings file for which the user has write permission.
197(<tt>INSTALL</tt> is the directory where Qt was installed. This can be
198modified by using the configure script's -prefix argument )
199<p> If you want to put the settings in a particular place in the
200filesystem you could do this:
201<pre>
202 settings.insertSearchPath( QSettings::<a href="#System-enum">Unix</a>, "/opt/MyCompany/share" );
203 </pre>
204
205<p> But in practice you may prefer not to use a search path for Unix.
206For example the following code:
207<pre>
208 settings.writeEntry( "/MyApplication/geometry/width", width );
209 </pre>
210
211will end up writing the "geometry/width" setting to the file
212<tt>$HOME/.qt/myapplicationrc</tt> (assuming that the application is
213being run by an ordinary user, i.e. not by root).
214<p> For cross-platform applications you should ensure that the
215<a href="#sizelimit">Windows size limitations</a> are not exceeded.
216<p> <b>Warning:</b> QSettings doesn't write the settings until it is destroyed so
217you should construct the QSettings object on the stack.
218<p>See also <a href="io.html">Input/Output and Networking</a> and <a href="misc.html">Miscellaneous Classes</a>.
219
220<hr><h2>Member Type Documentation</h2>
221<h3 class=fn><a name="Format-enum"></a>QSettings::Format</h3>
222
223<ul>
224<li><tt>QSettings::Native</tt> - Store the settings in a platform dependent location
225<li><tt>QSettings::Ini</tt> - Store the settings in a text file
226</ul>
227<h3 class=fn><a name="Scope-enum"></a>QSettings::Scope</h3>
228
229<ul>
230<li><tt>QSettings::Global</tt> - Save settings as global as possible
231<li><tt>QSettings::User</tt> - Save settings in user space
232</ul>
233<h3 class=fn><a name="System-enum"></a>QSettings::System</h3>
234
235<ul>
236<li><tt>QSettings::Mac</tt> - Macintosh execution environments
237<li><tt>QSettings::Unix</tt> - Mac OS X, Unix, Linux and Unix-like execution environments
238<li><tt>QSettings::Windows</tt> - Windows execution environments
239</ul>
240<hr><h2>Member Function Documentation</h2>
241<h3 class=fn><a name="QSettings"></a>QSettings::QSettings ()
242</h3>
243Creates a settings object.
244<p> Be aware that you must call <a href="#setPath">setPath</a>() or <a href="#insertSearchPath">insertSearchPath</a>() before
245you can use the QSettings object.
246
247<h3 class=fn><a name="QSettings-2"></a>QSettings::QSettings ( <a href="qsettings.html#Format-enum">Format</a>&nbsp;format )
248</h3>
249Creates a settings object. If <em>format</em> is 'Ini' the settings will
250be stored in a text file, using the Unix strategy (see above). If <em>format</em>
251is 'Native', the settings will be stored in a platform specific way
252(ie. the Windows registry).
253<p> Be aware that you must call <a href="#setPath">setPath</a>() or <a href="#insertSearchPath">insertSearchPath</a>() before
254you can use the QSettings object.
255
256<h3 class=fn><a name="~QSettings"></a>QSettings::~QSettings ()
257</h3>
258Destroys the settings object. All modifications made to the settings
259will automatically be saved.
260<p>
261<h3 class=fn>void <a name="beginGroup"></a>QSettings::beginGroup ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;group )
262</h3>
263Appends <em>group</em> to the current key prefix.
264<p> <pre>
265 QSettings settings;
266 settings.<a href="#beginGroup">beginGroup</a>( "/MainWindow" );
267 // read values
268 settings.<a href="#endGroup">endGroup</a>();
269 </pre>
270
271
272<h3 class=fn>void <a name="endGroup"></a>QSettings::endGroup ()
273</h3>
274Undo previous calls to <a href="#beginGroup">beginGroup</a>(). Note that a single beginGroup("a/b/c") is undone
275by a single call to <a href="#endGroup">endGroup</a>().
276<p> <pre>
277 QSettings settings;
278 settings.<a href="#beginGroup">beginGroup</a>( "/MainWindow/Geometry" );
279 // read values
280 settings.<a href="#endGroup">endGroup</a>();
281 </pre>
282
283
284<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="entryList"></a>QSettings::entryList ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key ) const
285</h3>
286Returns a list of the keys which contain entries under <em>key</em>. Does <em>not</em> return any keys that contain subkeys.
287<p> Example settings:
288<pre>
289 /MyCompany/MyApplication/background color
290 /MyCompany/MyApplication/foreground color
291 /MyCompany/MyApplication/geometry/x
292 /MyCompany/MyApplication/geometry/y
293 /MyCompany/MyApplication/geometry/width
294 /MyCompany/MyApplication/geometry/height
295 </pre>
296
297<pre>
298 <a href="qstringlist.html">QStringList</a> keys = settings.entryList( "/MyCompany/MyApplication" );
299 </pre>
300
301<p> In the above example, <tt>keys</tt> will contain 'background color' and
302'foreground color'. It will not contain 'geometry' because this key
303contains subkeys not entries.
304<p> To access the geometry values, you could either use <a href="#subkeyList">subkeyList</a>()
305to read the keys then read each entry, or simply read each entry
306directly by specifying its full key, e.g.
307"/MyCompany/MyApplication/geometry/y".
308<p> <p>See also <a href="#subkeyList">subkeyList</a>().
309
310<h3 class=fn><a href="qstring.html">QString</a> <a name="group"></a>QSettings::group () const
311</h3>
312Returns the current key prefix, or a null string if there is no key prefix set.
313<p> <p>See also <a href="#beginGroup">beginGroup</a>().
314
315<h3 class=fn>void <a name="insertSearchPath"></a>QSettings::insertSearchPath ( <a href="qsettings.html#System-enum">System</a>&nbsp;s, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;path )
316</h3>
317Inserts <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
318use <a href="#setPath">setPath</a>() instead of this function.
319<p> When <em>s</em> is <em>Windows</em> and the execution environment is <em>not</em>
320Windows the function does nothing. Similarly when <em>s</em> is <em>Unix</em> and
321the execution environment is <em>not</em> Unix the function does nothing.
322<p> When <em>s</em> is <em>Windows</em>, and the execution environment is Windows, the
323search path list will be used as the first subfolder of the "Software"
324folder in the registry.
325<p> When reading settings the folders are searched forwards from the
326first folder (listed below) to the last, returning the first
327settings found, and ignoring any folders for which the user doesn't
328have read permission.
329<ol type=1>
330<li> HKEY_CURRENT_USER/Software/MyCompany/MyApplication
331<li> HKEY_LOCAL_MACHINE/Software/MyCompany/MyApplication
332<li> HKEY_CURRENT_USER/Software/MyApplication
333<li> HKEY_LOCAL_MACHINE/Software/MyApplication
334</ol>
335<p> <pre>
336 QSettings settings;
337 settings.<a href="#insertSearchPath">insertSearchPath</a>( QSettings::<a href="#System-enum">Windows</a>, "/MyCompany" );
338 settings.<a href="#writeEntry">writeEntry</a>( "/MyApplication/Tip of the day", TRUE );
339 </pre>
340
341The 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
342which the user has write permission.
343<ol type=1>
344<li> HKEY_LOCAL_MACHINE/Software/MyCompany/MyApplication
345<li> HKEY_CURRENT_USER/Software/MyCompany/MyApplication
346<li> HKEY_LOCAL_MACHINE/Software/MyApplication
347<li> HKEY_CURRENT_USER/Software/MyApplication
348</ol>
349If a setting is found in the HKEY_CURRENT_USER space, this setting
350is overwritten independently of write permissions in the
351HKEY_LOCAL_MACHINE space.
352<p> When <em>s</em> is <em>Unix</em>, and the execution environment is Unix, the
353search path list will be used when trying to determine a suitable
354filename for reading and writing settings files. By default, there are
355two entries in the search path:
356<p> <ol type=1>
357<li> <tt>SYSCONF</tt> - where <tt>SYSCONF</tt> is a directory specified when
358configuring Qt; by default it is INSTALL/etc/settings.
359<li> <tt>$HOME/.qt/</tt> - where <tt>$HOME</tt> is the user's home directory.
360</ol>
361<p> All insertions into the search path will go before $HOME/.qt/.
362For example:
363<pre>
364 QSettings settings;
365 settings.<a href="#insertSearchPath">insertSearchPath</a>( QSettings::<a href="#System-enum">Unix</a>, "/opt/MyCompany/share/etc" );
366 settings.<a href="#insertSearchPath">insertSearchPath</a>( QSettings::<a href="#System-enum">Unix</a>, "/opt/MyCompany/share/MyApplication/etc" );
367 // ...
368 </pre>
369
370Will result in a search path of:
371<ol type=1>
372<li> SYSCONF
373<li> /opt/MyCompany/share/etc
374<li> /opt/MyCompany/share/MyApplication/etc
375<li> $HOME/.qt
376</ol>
377When reading settings the files are searched in the order shown
378above, with later settings overriding earlier settings. Files for
379which the user doesn't have read permission are ignored. When saving
380settings QSettings works in the order shown above, writing
381to the first settings file for which the user has write permission.
382<p> Note that paths in the file system are not created by this
383function, so they must already exist to be useful.
384<p> Settings under Unix are stored in files whose names are based on the
385first subkey of the key (not including the search path). The algorithm
386for creating names is essentially: lowercase the first subkey, replace
387spaces with underscores and add 'rc', e.g.
388<tt>/MyCompany/MyApplication/background color</tt> will be stored in
389<tt>myapplicationrc</tt> (assuming that <tt>/MyCompany</tt> is part of
390the search path).
391<p> <p>See also <a href="#removeSearchPath">removeSearchPath</a>().
392
393<p>
394<p>Example: <a href="canvas-chart-example.html#x2890">chart/chartform.cpp</a>.
395<h3 class=fn>bool <a name="readBoolEntry"></a>QSettings::readBoolEntry ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key, bool&nbsp;def = FALSE, bool&nbsp;*&nbsp;ok = 0 ) const
396</h3>
397
398<p> Reads the entry specified by <em>key</em>, and returns a bool, or the
399default value, <em>def</em>, if the entry couldn't be read.
400If <em>ok</em> is non-null, *ok is set to TRUE if the key was read, FALSE
401otherwise.
402<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>().
403
404<h3 class=fn>double <a name="readDoubleEntry"></a>QSettings::readDoubleEntry ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key, double&nbsp;def = 0, bool&nbsp;*&nbsp;ok = 0 ) const
405</h3>
406
407<p> Reads the entry specified by <em>key</em>, and returns a double, or the
408default value, <em>def</em>, if the entry couldn't be read.
409If <em>ok</em> is non-null, *ok is set to TRUE if the key was read, FALSE
410otherwise.
411<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>().
412
413<h3 class=fn><a href="qstring.html">QString</a> <a name="readEntry"></a>QSettings::readEntry ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;def = QString::null, bool&nbsp;*&nbsp;ok = 0 ) const
414</h3>
415
416<p> Reads the entry specified by <em>key</em>, and returns a <a href="qstring.html">QString</a>, or the
417default value, <em>def</em>, if the entry couldn't be read.
418If <em>ok</em> is non-null, *ok is set to TRUE if the key was read, FALSE
419otherwise.
420<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>().
421
422<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="readListEntry"></a>QSettings::readListEntry ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key, bool&nbsp;*&nbsp;ok = 0 ) const
423</h3>
424
425Reads the entry specified by <em>key</em> as a string. If <em>ok</em> is not
4260, <em>*ok</em> is set to TRUE if the key was read, otherwise <em>*ok</em> is
427set to FALSE.
428<p> Note that if you want to iterate over the list, you should iterate
429over a copy, e.g.
430<pre>
431 <a href="qstringlist.html">QStringList</a> list = mySettings.readListEntry( "recentfiles" );
432 QStringList::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>();
433 while( it != list.<a href="qvaluelist.html#end">end</a>() ) {
434 myProcessing( *it );
435 ++it;
436 }
437 </pre>
438
439<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="qstringlist.html#split">QStringList::split</a>().
440
441<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="readListEntry-4"></a>QSettings::readListEntry ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key, const&nbsp;<a href="qchar.html">QChar</a>&nbsp;&amp;&nbsp;separator, bool&nbsp;*&nbsp;ok = 0 ) const
442</h3>
443This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
444<p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
445<p> Reads the entry specified by <em>key</em> as a string. The <em>separator</em>
446is used to create a <a href="qstringlist.html">QStringList</a> by calling <a href="qstringlist.html#split">QStringList::split</a>(<em>separator</em>, entry). If <em>ok</em> is not 0: <em>*ok</em> is set to TRUE
447if the key was read, otherwise <em>*ok</em> is set to FALSE.
448<p> <b>Warning:</b> As the documentation states, QStringList::split() will
449omit empty strings from the list. Because of this, it is
450impossible to retrieve identical list data with this function. We
451recommend using the <a href="#readListEntry">readListEntry</a>() and <a href="#writeEntry">writeEntry</a>() overloads
452that do not take a <em>separator</em> argument.
453<p> Note that if you want to iterate over the list, you should iterate
454over a copy, e.g.
455<pre>
456 <a href="qstringlist.html">QStringList</a> list = mySettings.readListEntry( "size", " " );
457 QStringList::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>();
458 while( it != list.<a href="qvaluelist.html#end">end</a>() ) {
459 myProcessing( *it );
460 ++it;
461 }
462 </pre>
463
464<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="qstringlist.html#split">QStringList::split</a>().
465
466<h3 class=fn>int <a name="readNumEntry"></a>QSettings::readNumEntry ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key, int&nbsp;def = 0, bool&nbsp;*&nbsp;ok = 0 ) const
467</h3>
468
469<p> Reads the entry specified by <em>key</em>, and returns an integer, or the
470default value, <em>def</em>, if the entry couldn't be read.
471If <em>ok</em> is non-null, *ok is set to TRUE if the key was read, FALSE
472otherwise.
473<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>().
474
475<h3 class=fn>bool <a name="removeEntry"></a>QSettings::removeEntry ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key )
476</h3>
477Removes the entry specified by <em>key</em>.
478<p> Returns true if the entry was successfully removed; otherwise
479returns false. Note that removing the last entry in any given
480folder, will also remove the folder.
481<p> <p>See also <a href="#readEntry">readEntry</a>() and <a href="#writeEntry">writeEntry</a>().
482
483<h3 class=fn>void <a name="removeSearchPath"></a>QSettings::removeSearchPath ( <a href="qsettings.html#System-enum">System</a>&nbsp;s, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;path )
484</h3>
485Removes all occurrences of <em>path</em> (using exact matching) from the
486settings search path for system <em>s</em>. Note that the default search
487paths cannot be removed.
488<p> <p>See also <a href="#insertSearchPath">insertSearchPath</a>().
489
490<h3 class=fn>void <a name="resetGroup"></a>QSettings::resetGroup ()
491</h3>
492Set the current key prefix to the empty string.
493
494<h3 class=fn>void <a name="setPath"></a>QSettings::setPath ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;domain, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;product, <a href="qsettings.html#Scope-enum">Scope</a>&nbsp;scope = Global )
495</h3>
496Insert platform-dependent paths from platform-independent information.
497<p> The <em>domain</em> should be an Internet domain name
498controlled by the producer of the software, eg. Trolltech products
499use "trolltech.com".
500<p> The <em>product</em> should be the official name of the product.
501<p> The <em>scope</em> should be
502QSettings::User for user-specific settings, or
503QSettings::Global for system-wide settings (generally
504these will be read-only to many users).
505<p> Not all information is relevant on all systems.
506
507<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="subkeyList"></a>QSettings::subkeyList ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key ) const
508</h3>
509Returns a list of the keys which contain subkeys under <em>key</em>. Does <em>not</em> return any keys that contain entries.
510<p> Example settings:
511<pre>
512 /MyCompany/MyApplication/background color
513 /MyCompany/MyApplication/foreground color
514 /MyCompany/MyApplication/geometry/x
515 /MyCompany/MyApplication/geometry/y
516 /MyCompany/MyApplication/geometry/width
517 /MyCompany/MyApplication/geometry/height
518 /MyCompany/MyApplication/recent files/1
519 /MyCompany/MyApplication/recent files/2
520 /MyCompany/MyApplication/recent files/3
521 </pre>
522
523<pre>
524 <a href="qstringlist.html">QStringList</a> keys = settings.subkeyList( "/MyCompany/MyApplication" );
525 </pre>
526
527<p> In the above example, <tt>keys</tt> will contain 'geometry' and
528'recent files'. It will not contain 'background color' or
529'foreground color' because those keys contain entries not
530subkeys. To get a list of keys that contain entries rather than
531subkeys use <a href="#entryList">entryList</a>() instead.
532<p> <b>Warning:</b> In the above example, if QSettings is writing to an Ini file,
533then a call to
534<pre> subkeyList("/MyCompany") </pre>
535
536will return an empty list. This happens because a key like
537<pre> /MyCompany/MyApplication/background color </pre>
538
539is written to the file <em>"mycompanyrc"</em>, under the section <em>[MyApplication]</em>.
540This call is therefore a request to list the sections in an ini file, which
541is not supported in this version of QSettings. This is a known issue which
542will be fixed in Qt-4.
543<p> <p>See also <a href="#entryList">entryList</a>().
544
545<h3 class=fn>bool <a name="writeEntry"></a>QSettings::writeEntry ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key, bool&nbsp;value )
546</h3>
547Writes the boolean entry <em>value</em> into key <em>key</em>. The <em>key</em> is
548created if it doesn't exist. Any previous value is overwritten by <em>value</em>.
549<p> If an error occurs the settings are left unchanged and FALSE is
550returned; otherwise TRUE is returned.
551<p> <b>Warning:</b> On certain platforms, keys are required to contain at least
552two components (e.g., "/foo/bar"). This limitation does not apply to
553Qt 4.
554<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>().
555
556<p>Example: <a href="canvas-chart-example.html#x2891">chart/chartform.cpp</a>.
557<h3 class=fn>bool <a name="writeEntry-2"></a>QSettings::writeEntry ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key, double&nbsp;value )
558</h3>
559This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
560<p> Writes the double entry <em>value</em> into key <em>key</em>. The <em>key</em> is
561created if it doesn't exist. Any previous value is overwritten by <em>value</em>.
562<p> If an error occurs the settings are left unchanged and FALSE is
563returned; otherwise TRUE is returned.
564<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>().
565
566<h3 class=fn>bool <a name="writeEntry-3"></a>QSettings::writeEntry ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key, int&nbsp;value )
567</h3>
568This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
569<p> Writes the integer entry <em>value</em> into key <em>key</em>. The <em>key</em> is
570created if it doesn't exist. Any previous value is overwritten by <em>value</em>.
571<p> If an error occurs the settings are left unchanged and FALSE is
572returned; otherwise TRUE is returned.
573<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>().
574
575<h3 class=fn>bool <a name="writeEntry-5"></a>QSettings::writeEntry ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;value )
576</h3>
577This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
578<p> Writes the string entry <em>value</em> into key <em>key</em>. The <em>key</em> is
579created 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
580value will be an empty string.
581<p> If an error occurs the settings are left unchanged and FALSE is
582returned; otherwise TRUE is returned.
583<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>().
584
585<h3 class=fn>bool <a name="writeEntry-6"></a>QSettings::writeEntry ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key, const&nbsp;<a href="qstringlist.html">QStringList</a>&nbsp;&amp;&nbsp;value )
586</h3>
587This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
588<p> Writes the string list entry <em>value</em> into key <em>key</em>. The <em>key</em>
589is created if it doesn't exist. Any previous value is overwritten
590by <em>value</em>.
591<p> If an error occurs the settings are left unchanged and FALSE is
592returned; otherwise returns TRUE.
593<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>().
594
595<h3 class=fn>bool <a name="writeEntry-7"></a>QSettings::writeEntry ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;key, const&nbsp;<a href="qstringlist.html">QStringList</a>&nbsp;&amp;&nbsp;value, const&nbsp;<a href="qchar.html">QChar</a>&nbsp;&amp;&nbsp;separator )
596</h3>
597This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
598<p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
599<p> Writes the string list entry <em>value</em> into key <em>key</em>. The <em>key</em>
600is created if it doesn't exist. Any previous value is overwritten
601by <em>value</em>. The list is stored as a sequence of strings separated
602by <em>separator</em> (using <a href="qstringlist.html#join">QStringList::join</a>()), so none of the
603strings in the list should contain the separator. If the list is
604empty or null the key's value will be an empty string.
605<p> <b>Warning:</b> The list should not contain empty or null strings, as
606<a href="#readListEntry">readListEntry</a>() will use <a href="qstringlist.html#split">QStringList::split</a>() to recreate the
607list. As the documentation states, QStringList::split() will omit
608empty strings from the list. Because of this, it is impossible to
609retrieve identical list data that is stored with this function.
610We recommend using the <a href="#writeEntry">writeEntry</a>() and readListEntry() overloads
611that do not take a <em>separator</em> argument.
612<p> If an error occurs the settings are left unchanged and FALSE is
613returned; otherwise returns TRUE.
614<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="qstringlist.html#join">QStringList::join</a>().
615
616<!-- eof -->
617<hr><p>
618This file is part of the <a href="index.html">Qt toolkit</a>.
619Copyright &copy; 1995-2007
620<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
621<table width=100% cellspacing=0 border=0><tr>
622<td>Copyright &copy; 2007
623<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
624<td align=right><div align=right>Qt 3.3.8</div>
625</table></div></address></body>
626</html>
Note: See TracBrowser for help on using the repository browser.