1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
|
<!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>QSettings 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 Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped 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>QSettings Class Reference</h1>
<p>The QSettings class provides persistent platform-independent application settings.
<a href="#details">More...</a>
<p><tt>#include <<a href="qsettings-h.html">qsettings.h</a>></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="#QSettings"><b>QSettings</b></a> ()</li>
<li class=fn><a href="#QSettings-2"><b>QSettings</b></a> ( Format format )</li>
<li class=fn><a href="#~QSettings"><b>~QSettings</b></a> ()</li>
<li class=fn>bool <a href="#writeEntry"><b>writeEntry</b></a> ( const QString & key, bool value )</li>
<li class=fn>bool <a href="#writeEntry-2"><b>writeEntry</b></a> ( const QString & key, double value )</li>
<li class=fn>bool <a href="#writeEntry-3"><b>writeEntry</b></a> ( const QString & key, int value )</li>
<li class=fn>bool <a href="#writeEntry-5"><b>writeEntry</b></a> ( const QString & key, const QString & value )</li>
<li class=fn>bool <a href="#writeEntry-6"><b>writeEntry</b></a> ( const QString & key, const QStringList & value )</li>
<li class=fn>bool writeEntry ( const QString & key, const QStringList & value, const QChar & separator ) <em>(obsolete)</em></li>
<li class=fn>QStringList <a href="#entryList"><b>entryList</b></a> ( const QString & key ) const</li>
<li class=fn>QStringList <a href="#subkeyList"><b>subkeyList</b></a> ( const QString & key ) const</li>
<li class=fn>QStringList <a href="#readListEntry"><b>readListEntry</b></a> ( const QString & key, bool * ok = 0 ) const</li>
<li class=fn>QStringList readListEntry ( const QString & key, const QChar & separator, bool * ok = 0 ) const <em>(obsolete)</em></li>
<li class=fn>QString <a href="#readEntry"><b>readEntry</b></a> ( const QString & key, const QString & def = QString::null, bool * ok = 0 ) const</li>
<li class=fn>int <a href="#readNumEntry"><b>readNumEntry</b></a> ( const QString & key, int def = 0, bool * ok = 0 ) const</li>
<li class=fn>double <a href="#readDoubleEntry"><b>readDoubleEntry</b></a> ( const QString & key, double def = 0, bool * ok = 0 ) const</li>
<li class=fn>bool <a href="#readBoolEntry"><b>readBoolEntry</b></a> ( const QString & key, bool def = FALSE, bool * ok = 0 ) const</li>
<li class=fn>bool <a href="#removeEntry"><b>removeEntry</b></a> ( const QString & key )</li>
<li class=fn>void <a href="#insertSearchPath"><b>insertSearchPath</b></a> ( System s, const QString & path )</li>
<li class=fn>void <a href="#removeSearchPath"><b>removeSearchPath</b></a> ( System s, const QString & path )</li>
<li class=fn>void <a href="#setPath"><b>setPath</b></a> ( const QString & domain, const QString & product, Scope scope = Global )</li>
<li class=fn>void <a href="#beginGroup"><b>beginGroup</b></a> ( const QString & 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>QString <a href="#group"><b>group</b></a> () const</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The QSettings class provides persistent platform-independent application settings.
<p>
<p> 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.
<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 QSettings to save the settings
for each individual application and <a href="qsessionmanager.html">QSessionManager</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>
QSettings settings;
settings.<a href="#setPath">setPath</a>( "MyCompany.com", "MyApplication" );
<a href="qstring.html">QString</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>
QSettings 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>
QSettings 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="qstringlist.html">QStringList</a> keys = settings.entryList( "/MyApplication" );
// keys contains 'background color' and 'foreground color'.
<a href="qstringlist.html">QStringList</a> keys = settings.entryList( "/MyApplication/recent files" );
// keys contains '1', '2' and '3'.
<a href="qstringlist.html">QStringList</a> subkeys = settings.subkeyList( "/MyApplication" );
// subkeys contains 'geometry' and 'recent files'
<a href="qstringlist.html">QStringList</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 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.
<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). QSettings will
create an appropriate plist file (<tt>com.<first group name>.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 QSettings 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 Qt 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( QSettings::<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> QSettings doesn't write the settings until it is destroyed so
you should construct the QSettings 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>QSettings::Format</h3>
<ul>
<li><tt>QSettings::Native</tt> - Store the settings in a platform dependent location
<li><tt>QSettings::Ini</tt> - Store the settings in a text file
</ul>
<h3 class=fn><a name="Scope-enum"></a>QSettings::Scope</h3>
<ul>
<li><tt>QSettings::Global</tt> - Save settings as global as possible
<li><tt>QSettings::User</tt> - Save settings in user space
</ul>
<h3 class=fn><a name="System-enum"></a>QSettings::System</h3>
<ul>
<li><tt>QSettings::Mac</tt> - Macintosh execution environments
<li><tt>QSettings::Unix</tt> - Mac OS X, Unix, Linux and Unix-like execution environments
<li><tt>QSettings::Windows</tt> - Windows execution environments
</ul>
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QSettings"></a>QSettings::QSettings ()
</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 QSettings object.
<h3 class=fn><a name="QSettings-2"></a>QSettings::QSettings ( <a href="qsettings.html#Format-enum">Format</a> 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 QSettings object.
<h3 class=fn><a name="~QSettings"></a>QSettings::~QSettings ()
</h3>
Destroys the settings object. All modifications made to the settings
will automatically be saved.
<p>
<h3 class=fn>void <a name="beginGroup"></a>QSettings::beginGroup ( const <a href="qstring.html">QString</a> & group )
</h3>
Appends <em>group</em> to the current key prefix.
<p> <pre>
QSettings 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>QSettings::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>
QSettings settings;
settings.<a href="#beginGroup">beginGroup</a>( "/MainWindow/Geometry" );
// read values
settings.<a href="#endGroup">endGroup</a>();
</pre>
<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="entryList"></a>QSettings::entryList ( const <a href="qstring.html">QString</a> & 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="qstringlist.html">QStringList</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="qstring.html">QString</a> <a name="group"></a>QSettings::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>QSettings::insertSearchPath ( <a href="qsettings.html#System-enum">System</a> s, const <a href="qstring.html">QString</a> & 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>
QSettings settings;
settings.<a href="#insertSearchPath">insertSearchPath</a>( QSettings::<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 Qt; 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>
QSettings settings;
settings.<a href="#insertSearchPath">insertSearchPath</a>( QSettings::<a href="#System-enum">Unix</a>, "/opt/MyCompany/share/etc" );
settings.<a href="#insertSearchPath">insertSearchPath</a>( QSettings::<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 QSettings 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>QSettings::readBoolEntry ( const <a href="qstring.html">QString</a> & key, bool def = FALSE, bool * 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>QSettings::readDoubleEntry ( const <a href="qstring.html">QString</a> & key, double def = 0, bool * 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="qstring.html">QString</a> <a name="readEntry"></a>QSettings::readEntry ( const <a href="qstring.html">QString</a> & key, const <a href="qstring.html">QString</a> & def = QString::null, bool * ok = 0 ) const
</h3>
<p> Reads the entry specified by <em>key</em>, and returns a <a href="qstring.html">QString</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="qstringlist.html">QStringList</a> <a name="readListEntry"></a>QSettings::readListEntry ( const <a href="qstring.html">QString</a> & key, bool * 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="qstringlist.html">QStringList</a> list = mySettings.readListEntry( "recentfiles" );
QStringList::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>();
while( it != list.<a href="qvaluelist.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="qstringlist.html#split">QStringList::split</a>().
<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="readListEntry-4"></a>QSettings::readListEntry ( const <a href="qstring.html">QString</a> & key, const <a href="qchar.html">QChar</a> & separator, bool * 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="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
if the key was read, otherwise <em>*ok</em> is set to FALSE.
<p> <b>Warning:</b> 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 <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="qstringlist.html">QStringList</a> list = mySettings.readListEntry( "size", " " );
QStringList::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>();
while( it != list.<a href="qvaluelist.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="qstringlist.html#split">QStringList::split</a>().
<h3 class=fn>int <a name="readNumEntry"></a>QSettings::readNumEntry ( const <a href="qstring.html">QString</a> & key, int def = 0, bool * 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>QSettings::removeEntry ( const <a href="qstring.html">QString</a> & 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>QSettings::removeSearchPath ( <a href="qsettings.html#System-enum">System</a> s, const <a href="qstring.html">QString</a> & 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>QSettings::resetGroup ()
</h3>
Set the current key prefix to the empty string.
<h3 class=fn>void <a name="setPath"></a>QSettings::setPath ( const <a href="qstring.html">QString</a> & domain, const <a href="qstring.html">QString</a> & product, <a href="qsettings.html#Scope-enum">Scope</a> 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
QSettings::User for user-specific settings, or
QSettings::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="qstringlist.html">QStringList</a> <a name="subkeyList"></a>QSettings::subkeyList ( const <a href="qstring.html">QString</a> & 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="qstringlist.html">QStringList</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 QSettings 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 QSettings. This is a known issue which
will be fixed in Qt-4.
<p> <p>See also <a href="#entryList">entryList</a>().
<h3 class=fn>bool <a name="writeEntry"></a>QSettings::writeEntry ( const <a href="qstring.html">QString</a> & key, bool 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
Qt 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>QSettings::writeEntry ( const <a href="qstring.html">QString</a> & key, double 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>QSettings::writeEntry ( const <a href="qstring.html">QString</a> & key, int 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>QSettings::writeEntry ( const <a href="qstring.html">QString</a> & key, const <a href="qstring.html">QString</a> & 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>QSettings::writeEntry ( const <a href="qstring.html">QString</a> & key, const <a href="qstringlist.html">QStringList</a> & 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>QSettings::writeEntry ( const <a href="qstring.html">QString</a> & key, const <a href="qstringlist.html">QStringList</a> & value, const <a href="qchar.html">QChar</a> & 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="qstringlist.html#join">QStringList::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="qstringlist.html#split">QStringList::split</a>() 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 <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="qstringlist.html#join">QStringList::join</a>().
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright © 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 © 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt 3.3.8</div>
</table></div></address></body>
</html>
|