summaryrefslogtreecommitdiffstats
path: root/doc/man/man3/qsettings.3qt
blob: f9509cb2991d1ddb27326283f1663d4509a5ac6e (plain)
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
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
'\" t
.TH QSettings 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA.  All rights reserved.  See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QSettings \- Persistent platform-independent application settings
.SH SYNOPSIS
\fC#include <qsettings.h>\fR
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "enum \fBFormat\fR { Native = 0, Ini }"
.br
.ti -1c
.BI "enum \fBSystem\fR { Unix = 0, Windows, Mac }"
.br
.ti -1c
.BI "enum \fBScope\fR { User, Global }"
.br
.ti -1c
.BI "\fBQSettings\fR ()"
.br
.ti -1c
.BI "\fBQSettings\fR ( Format format )"
.br
.ti -1c
.BI "\fB~QSettings\fR ()"
.br
.ti -1c
.BI "bool \fBwriteEntry\fR ( const QString & key, bool value )"
.br
.ti -1c
.BI "bool \fBwriteEntry\fR ( const QString & key, double value )"
.br
.ti -1c
.BI "bool \fBwriteEntry\fR ( const QString & key, int value )"
.br
.ti -1c
.BI "bool \fBwriteEntry\fR ( const QString & key, const QString & value )"
.br
.ti -1c
.BI "bool \fBwriteEntry\fR ( const QString & key, const QStringList & value )"
.br
.ti -1c
.BI "bool writeEntry ( const QString & key, const QStringList & value, const QChar & separator )  \fI(obsolete)\fR"
.br
.ti -1c
.BI "QStringList \fBentryList\fR ( const QString & key ) const"
.br
.ti -1c
.BI "QStringList \fBsubkeyList\fR ( const QString & key ) const"
.br
.ti -1c
.BI "QStringList \fBreadListEntry\fR ( const QString & key, bool * ok = 0 ) const"
.br
.ti -1c
.BI "QStringList readListEntry ( const QString & key, const QChar & separator, bool * ok = 0 ) const  \fI(obsolete)\fR"
.br
.ti -1c
.BI "QString \fBreadEntry\fR ( const QString & key, const QString & def = QString::null, bool * ok = 0 ) const"
.br
.ti -1c
.BI "int \fBreadNumEntry\fR ( const QString & key, int def = 0, bool * ok = 0 ) const"
.br
.ti -1c
.BI "double \fBreadDoubleEntry\fR ( const QString & key, double def = 0, bool * ok = 0 ) const"
.br
.ti -1c
.BI "bool \fBreadBoolEntry\fR ( const QString & key, bool def = FALSE, bool * ok = 0 ) const"
.br
.ti -1c
.BI "bool \fBremoveEntry\fR ( const QString & key )"
.br
.ti -1c
.BI "void \fBinsertSearchPath\fR ( System s, const QString & path )"
.br
.ti -1c
.BI "void \fBremoveSearchPath\fR ( System s, const QString & path )"
.br
.ti -1c
.BI "void \fBsetPath\fR ( const QString & domain, const QString & product, Scope scope = Global )"
.br
.ti -1c
.BI "void \fBbeginGroup\fR ( const QString & group )"
.br
.ti -1c
.BI "void \fBendGroup\fR ()"
.br
.ti -1c
.BI "void \fBresetGroup\fR ()"
.br
.ti -1c
.BI "QString \fBgroup\fR () const"
.br
.in -1c
.SH DESCRIPTION
The QSettings class provides persistent platform-independent application settings.
.PP
On Unix systems, QSettings uses text files to store settings. On Windows systems, QSettings uses the system registry. On Mac OS X, QSettings uses the Carbon preferences API.
.PP
Each setting comprises an identifying key and the data associated with the key. A key is a unicode string which consists of \fItwo\fR or more subkeys. A subkey is a slash, '/', followed by one or more unicode characters (excluding slashes, newlines, carriage returns and equals, '=', signs). The associated data, called the entry or value, may be a boolean, an integer, a double, a string or a list of strings. Entry strings may contain any unicode characters.
.PP
If you want to save and restore the entire desktop's settings, i.e. which applications are running, use QSettings to save the settings for each individual application and QSessionManager to save the desktop's session.
.PP
Example settings:
.PP
.nf
.br
    /MyCompany/MyApplication/background color
.br
    /MyCompany/MyApplication/foreground color
.br
    /MyCompany/MyApplication/geometry/x
.br
    /MyCompany/MyApplication/geometry/y
.br
    /MyCompany/MyApplication/geometry/width
.br
    /MyCompany/MyApplication/geometry/height
.br
    /MyCompany/MyApplication/recent files/1
.br
    /MyCompany/MyApplication/recent files/2
.br
    /MyCompany/MyApplication/recent files/3
.br
.fi
Each line above is a complete key, made up of subkeys.
.PP
A typical usage pattern for reading settings at application startup:
.PP
.nf
.br
    QSettings settings;
.br
    settings.setPath( "MyCompany.com", "MyApplication" );
.br
.br
    QString bgColor = settings.readEntry( "/colors/background", "white" );
.br
    int width = settings.readNumEntry( "/geometry/width", 640 );
.br
    // ...
.br
.fi
.PP
A typical usage pattern for saving settings at application exit or 'save preferences':
.PP
.nf
.br
    QSettings settings;
.br
    settings.setPath( "MyCompany.com", "MyApplication" );
.br
.br
    settings.writeEntry( "/colors/background", bgColor );
.br
    settings.writeEntry( "/geometry/width", width );
.br
    // ...
.br
.fi
.PP
A key prefix can be prepended to all keys using beginGroup(). The application of the prefix is stopped using endGroup(). For example:
.PP
.nf
.br
    QSettings settings;
.br
.br
    settings.beginGroup( "/MainWindow" );
.br
        settings.beginGroup( "/Geometry" );
.br
            int x = settings.readEntry( "/x" );
.br
            // ...
.br
        settings.endGroup();
.br
        settings.beginGroup( "/Toolbars" );
.br
            // ...
.br
        settings.endGroup();
.br
    settings.endGroup();
.br
.fi
.PP
You can get a list of entry-holding keys by calling entryList(), and a list of key-holding keys using subkeyList().
.PP
.nf
.br
    QStringList keys = settings.entryList( "/MyApplication" );
.br
    // keys contains 'background color' and 'foreground color'.
.br
.br
    QStringList keys = settings.entryList( "/MyApplication/recent files" );
.br
    // keys contains '1', '2' and '3'.
.br
.br
    QStringList subkeys = settings.subkeyList( "/MyApplication" );
.br
    // subkeys contains 'geometry' and 'recent files'
.br
.br
    QStringList subkeys = settings.subkeyList( "/MyApplication/recent files" );
.br
    // subkeys is empty.
.br
.fi
.PP
Since settings for Windows are stored in the registry there are some size limitations as follows:
.TP
A subkey may not exceed 255 characters.
.TP
An entry's value may not exceed 16,300 characters.
.TP
All the values of a key (for example, all the 'recent files' subkeys values), may not exceed 65,535 characters.
.PP
These limitations are not enforced on Unix or Mac OS X.
.PP
\fBWarning:\fR Creating multiple, simultaneous instances of QSettings writing to a text file may lead to data loss! This is a known issue which will be fixed in a future release of Qt.
.SH "Notes for Mac OS X Applications"
The location where settings are stored is not formally defined by the CFPreferences API.
.PP
At the time of writing settings are stored (either on a global or user basis, preferring locally) into a plist file in \fC$ROOT/System/Library/Preferences\fR (in XML format). QSettings will create an appropriate plist file (\fCcom.<first group name>.plist\fR) out of the full path to a key.
.PP
For further information on CFPreferences see Apple's Specifications
.SH "Notes for Unix Applications"
There is no universally accepted place for storing application settings under Unix. In the examples the settings file will be searched for in the following directories: <ol type=1>
.TP
\fCSYSCONF\fR - the default value is \fCINSTALL/etc/settings\fR
.TP
\fC/opt/MyCompany/share/etc\fR
.TP
\fC/opt/MyCompany/share/MyApplication/etc\fR
.TP
\fC$HOME/.qt\fR When reading settings the files are searched in the order shown above, with later settings overriding earlier settings. Files for which the user doesn't have read permission are ignored. When saving settings QSettings works in the order shown above, writing to the first settings file for which the user has write permission. (\fCINSTALL\fR is the directory where Qt was installed. This can be modified by using the configure script's -prefix argument )
.PP
If you want to put the settings in a particular place in the filesystem you could do this:
.PP
.nf
.br
    settings.insertSearchPath( QSettings::Unix, "/opt/MyCompany/share" );
.br
.fi
.PP
But in practice you may prefer not to use a search path for Unix. For example the following code:
.PP
.nf
.br
    settings.writeEntry( "/MyApplication/geometry/width", width );
.br
.fi
will end up writing the "geometry/width" setting to the file \fC$HOME/.qt/myapplicationrc\fR (assuming that the application is being run by an ordinary user, i.e. not by root).
.PP
For cross-platform applications you should ensure that the Windows size limitations are not exceeded.
.PP
\fBWarning:\fR QSettings doesn't write the settings until it is destroyed so you should construct the QSettings object on the stack.
.PP
See also Input/Output and Networking and Miscellaneous Classes.
.SS "Member Type Documentation"
.SH "QSettings::Format"
.TP
\fCQSettings::Native\fR - Store the settings in a platform dependent location
.TP
\fCQSettings::Ini\fR - Store the settings in a text file
.SH "QSettings::Scope"
.TP
\fCQSettings::Global\fR - Save settings as global as possible
.TP
\fCQSettings::User\fR - Save settings in user space
.SH "QSettings::System"
.TP
\fCQSettings::Mac\fR - Macintosh execution environments
.TP
\fCQSettings::Unix\fR - Mac OS X, Unix, Linux and Unix-like execution environments
.TP
\fCQSettings::Windows\fR - Windows execution environments
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QSettings::QSettings ()"
Creates a settings object.
.PP
Be aware that you must call setPath() or insertSearchPath() before you can use the QSettings object.
.SH "QSettings::QSettings ( Format format )"
Creates a settings object. If \fIformat\fR is 'Ini' the settings will be stored in a text file, using the Unix strategy (see above). If \fIformat\fR is 'Native', the settings will be stored in a platform specific way (ie. the Windows registry).
.PP
Be aware that you must call setPath() or insertSearchPath() before you can use the QSettings object.
.SH "QSettings::~QSettings ()"
Destroys the settings object. All modifications made to the settings will automatically be saved.
.SH "void QSettings::beginGroup ( const QString & group )"
Appends \fIgroup\fR to the current key prefix.
.PP
.nf
.br
    QSettings settings;
.br
    settings.beginGroup( "/MainWindow" );
.br
    // read values
.br
    settings.endGroup();
.br
.fi
.SH "void QSettings::endGroup ()"
Undo previous calls to beginGroup(). Note that a single beginGroup("a/b/c") is undone by a single call to endGroup().
.PP
.nf
.br
    QSettings settings;
.br
    settings.beginGroup( "/MainWindow/Geometry" );
.br
    // read values
.br
    settings.endGroup();
.br
.fi
.SH "QStringList QSettings::entryList ( const QString & key ) const"
Returns a list of the keys which contain entries under \fIkey\fR. Does \fInot\fR return any keys that contain subkeys.
.PP
Example settings:
.PP
.nf
.br
    /MyCompany/MyApplication/background color
.br
    /MyCompany/MyApplication/foreground color
.br
    /MyCompany/MyApplication/geometry/x
.br
    /MyCompany/MyApplication/geometry/y
.br
    /MyCompany/MyApplication/geometry/width
.br
    /MyCompany/MyApplication/geometry/height
.br
.fi
.PP
.nf
.br
    QStringList keys = settings.entryList( "/MyCompany/MyApplication" );
.br
.fi
.PP
In the above example, \fCkeys\fR will contain 'background color' and 'foreground color'. It will not contain 'geometry' because this key contains subkeys not entries.
.PP
To access the geometry values, you could either use subkeyList() to read the keys then read each entry, or simply read each entry directly by specifying its full key, e.g." /MyCompany/MyApplication/geometry/y".
.PP
See also subkeyList().
.SH "QString QSettings::group () const"
Returns the current key prefix, or a null string if there is no key prefix set.
.PP
See also beginGroup().
.SH "void QSettings::insertSearchPath ( System s, const QString & path )"
Inserts \fIpath\fR into the settings search path. The semantics of \fIpath\fR depends on the system \fIs\fR. It is usually easier and better to use setPath() instead of this function.
.PP
When \fIs\fR is \fIWindows\fR and the execution environment is \fInot\fR Windows the function does nothing. Similarly when \fIs\fR is \fIUnix\fR and the execution environment is \fInot\fR Unix the function does nothing.
.PP
When \fIs\fR is \fIWindows\fR, and the execution environment is Windows, the search path list will be used as the first subfolder of the "Software" folder in the registry.
.PP
When reading settings the folders are searched forwards from the first folder (listed below) to the last, returning the first settings found, and ignoring any folders for which the user doesn't have read permission. <ol type=1>
.TP
HKEY_CURRENT_USER/Software/MyCompany/MyApplication
.TP
HKEY_LOCAL_MACHINE/Software/MyCompany/MyApplication
.TP
HKEY_CURRENT_USER/Software/MyApplication
.TP
HKEY_LOCAL_MACHINE/Software/MyApplication
.PP
.nf
.br
  QSettings settings;
.br
  settings.insertSearchPath( QSettings::Windows, "/MyCompany" );
.br
  settings.writeEntry( "/MyApplication/Tip of the day", TRUE );
.br
.fi
The code above will write the subkey "Tip of the day" into the \fIfirst\fR of the registry folders listed below that is found and for which the user has write permission. <ol type=1>
.TP
HKEY_LOCAL_MACHINE/Software/MyCompany/MyApplication
.TP
HKEY_CURRENT_USER/Software/MyCompany/MyApplication
.TP
HKEY_LOCAL_MACHINE/Software/MyApplication
.TP
HKEY_CURRENT_USER/Software/MyApplication If a setting is found in the HKEY_CURRENT_USER space, this setting is overwritten independently of write permissions in the HKEY_LOCAL_MACHINE space.
.PP
When \fIs\fR is \fIUnix\fR, and the execution environment is Unix, the search path list will be used when trying to determine a suitable filename for reading and writing settings files. By default, there are two entries in the search path:
.PP
<ol type=1>
.TP
\fCSYSCONF\fR - where \fCSYSCONF\fR is a directory specified when configuring Qt; by default it is INSTALL/etc/settings.
.TP
\fC$HOME/.qt/\fR - where \fC$HOME\fR is the user's home directory.
.PP
All insertions into the search path will go before $HOME/.qt/. For example:
.PP
.nf
.br
  QSettings settings;
.br
  settings.insertSearchPath( QSettings::Unix, "/opt/MyCompany/share/etc" );
.br
  settings.insertSearchPath( QSettings::Unix, "/opt/MyCompany/share/MyApplication/etc" );
.br
  // ...
.br
.fi
Will result in a search path of: <ol type=1>
.TP
SYSCONF
.TP
/opt/MyCompany/share/etc
.TP
/opt/MyCompany/share/MyApplication/etc
.TP
$HOME/.qt When reading settings the files are searched in the order shown above, with later settings overriding earlier settings. Files for which the user doesn't have read permission are ignored. When saving settings QSettings works in the order shown above, writing to the first settings file for which the user has write permission.
.PP
Note that paths in the file system are not created by this function, so they must already exist to be useful.
.PP
Settings under Unix are stored in files whose names are based on the first subkey of the key (not including the search path). The algorithm for creating names is essentially: lowercase the first subkey, replace spaces with underscores and add 'rc', e.g. \fC/MyCompany/MyApplication/background color\fR will be stored in \fCmyapplicationrc\fR (assuming that \fC/MyCompany\fR is part of the search path).
.PP
See also removeSearchPath().
.PP
Example: chart/chartform.cpp.
.SH "bool QSettings::readBoolEntry ( const QString & key, bool def = FALSE, bool * ok = 0 ) const"
Reads the entry specified by \fIkey\fR, and returns a bool, or the default value, \fIdef\fR, if the entry couldn't be read. If \fIok\fR is non-null, *ok is set to TRUE if the key was read, FALSE otherwise.
.PP
See also readEntry(), readNumEntry(), readDoubleEntry(), writeEntry(), and removeEntry().
.SH "double QSettings::readDoubleEntry ( const QString & key, double def = 0, bool * ok = 0 ) const"
Reads the entry specified by \fIkey\fR, and returns a double, or the default value, \fIdef\fR, if the entry couldn't be read. If \fIok\fR is non-null, *ok is set to TRUE if the key was read, FALSE otherwise.
.PP
See also readEntry(), readNumEntry(), readBoolEntry(), writeEntry(), and removeEntry().
.SH "QString QSettings::readEntry ( const QString & key, const QString & def = QString::null, bool * ok = 0 ) const"
Reads the entry specified by \fIkey\fR, and returns a QString, or the default value, \fIdef\fR, if the entry couldn't be read. If \fIok\fR is non-null, *ok is set to TRUE if the key was read, FALSE otherwise.
.PP
See also readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), writeEntry(), and removeEntry().
.SH "QStringList QSettings::readListEntry ( const QString & key, bool * ok = 0 ) const"
Reads the entry specified by \fIkey\fR as a string. If \fIok\fR is not 0, \fI*ok\fR is set to TRUE if the key was read, otherwise \fI*ok\fR is set to FALSE.
.PP
Note that if you want to iterate over the list, you should iterate over a copy, e.g.
.PP
.nf
.br
    QStringList list = mySettings.readListEntry( "recentfiles" );
.br
    QStringList::Iterator it = list.begin();
.br
    while( it != list.end() ) {
.br
        myProcessing( *it );
.br
        ++it;
.br
    }
.br
.fi
.PP
See also readEntry(), readDoubleEntry(), readBoolEntry(), writeEntry(), removeEntry(), and QStringList::split().
.SH "QStringList QSettings::readListEntry ( const QString & key, const QChar & separator, bool * ok = 0 ) const"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
Reads the entry specified by \fIkey\fR as a string. The \fIseparator\fR is used to create a QStringList by calling QStringList::split(\fIseparator\fR, entry). If \fIok\fR is not 0: \fI*ok\fR is set to TRUE if the key was read, otherwise \fI*ok\fR is set to FALSE.
.PP
\fBWarning:\fR As the documentation states, QStringList::split() will omit empty strings from the list. Because of this, it is impossible to retrieve identical list data with this function. We recommend using the readListEntry() and writeEntry() overloads that do not take a \fIseparator\fR argument.
.PP
Note that if you want to iterate over the list, you should iterate over a copy, e.g.
.PP
.nf
.br
    QStringList list = mySettings.readListEntry( "size", " " );
.br
    QStringList::Iterator it = list.begin();
.br
    while( it != list.end() ) {
.br
        myProcessing( *it );
.br
        ++it;
.br
    }
.br
.fi
.PP
See also readEntry(), readDoubleEntry(), readBoolEntry(), writeEntry(), removeEntry(), and QStringList::split().
.SH "int QSettings::readNumEntry ( const QString & key, int def = 0, bool * ok = 0 ) const"
Reads the entry specified by \fIkey\fR, and returns an integer, or the default value, \fIdef\fR, if the entry couldn't be read. If \fIok\fR is non-null, *ok is set to TRUE if the key was read, FALSE otherwise.
.PP
See also readEntry(), readDoubleEntry(), readBoolEntry(), writeEntry(), and removeEntry().
.SH "bool QSettings::removeEntry ( const QString & key )"
Removes the entry specified by \fIkey\fR.
.PP
Returns true if the entry was successfully removed; otherwise returns false. Note that removing the last entry in any given folder, will also remove the folder.
.PP
See also readEntry() and writeEntry().
.SH "void QSettings::removeSearchPath ( System s, const QString & path )"
Removes all occurrences of \fIpath\fR (using exact matching) from the settings search path for system \fIs\fR. Note that the default search paths cannot be removed.
.PP
See also insertSearchPath().
.SH "void QSettings::resetGroup ()"
Set the current key prefix to the empty string.
.SH "void QSettings::setPath ( const QString & domain, const QString & product, Scope scope = Global )"
Insert platform-dependent paths from platform-independent information.
.PP
The \fIdomain\fR should be an Internet domain name controlled by the producer of the software, eg. Trolltech products use "trolltech.com".
.PP
The \fIproduct\fR should be the official name of the product.
.PP
The \fIscope\fR should be QSettings::User for user-specific settings, or QSettings::Global for system-wide settings (generally these will be read-only to many users).
.PP
Not all information is relevant on all systems.
.SH "QStringList QSettings::subkeyList ( const QString & key ) const"
Returns a list of the keys which contain subkeys under \fIkey\fR. Does \fInot\fR return any keys that contain entries.
.PP
Example settings:
.PP
.nf
.br
    /MyCompany/MyApplication/background color
.br
    /MyCompany/MyApplication/foreground color
.br
    /MyCompany/MyApplication/geometry/x
.br
    /MyCompany/MyApplication/geometry/y
.br
    /MyCompany/MyApplication/geometry/width
.br
    /MyCompany/MyApplication/geometry/height
.br
    /MyCompany/MyApplication/recent files/1
.br
    /MyCompany/MyApplication/recent files/2
.br
    /MyCompany/MyApplication/recent files/3
.br
.fi
.PP
.nf
.br
    QStringList keys = settings.subkeyList( "/MyCompany/MyApplication" );
.br
.fi
.PP
In the above example, \fCkeys\fR will contain 'geometry' and 'recent files'. It will not contain 'background color' or 'foreground color' because those keys contain entries not subkeys. To get a list of keys that contain entries rather than subkeys use entryList() instead.
.PP
\fBWarning:\fR In the above example, if QSettings is writing to an Ini file, then a call to
.PP
.nf
.br
 subkeyList("/MyCompany") 
.fi
will return an empty list. This happens because a key like
.PP
.nf
.br
 /MyCompany/MyApplication/background color 
.fi
is written to the file \fI"mycompanyrc"\fR, under the section \fI[MyApplication]\fR. This call is therefore a request to list the sections in an ini file, which is not supported in this version of QSettings. This is a known issue which will be fixed in Qt-4.
.PP
See also entryList().
.SH "bool QSettings::writeEntry ( const QString & key, bool value )"
Writes the boolean entry \fIvalue\fR into key \fIkey\fR. The \fIkey\fR is created if it doesn't exist. Any previous value is overwritten by \fIvalue\fR.
.PP
If an error occurs the settings are left unchanged and FALSE is returned; otherwise TRUE is returned.
.PP
\fBWarning:\fR On certain platforms, keys are required to contain at least two components (e.g., "/foo/bar"). This limitation does not apply to Qt 4.
.PP
See also readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), and removeEntry().
.PP
Example: chart/chartform.cpp.
.SH "bool QSettings::writeEntry ( const QString & key, double value )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Writes the double entry \fIvalue\fR into key \fIkey\fR. The \fIkey\fR is created if it doesn't exist. Any previous value is overwritten by \fIvalue\fR.
.PP
If an error occurs the settings are left unchanged and FALSE is returned; otherwise TRUE is returned.
.PP
See also readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), and removeEntry().
.SH "bool QSettings::writeEntry ( const QString & key, int value )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Writes the integer entry \fIvalue\fR into key \fIkey\fR. The \fIkey\fR is created if it doesn't exist. Any previous value is overwritten by \fIvalue\fR.
.PP
If an error occurs the settings are left unchanged and FALSE is returned; otherwise TRUE is returned.
.PP
See also readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), and removeEntry().
.SH "bool QSettings::writeEntry ( const QString & key, const QString & value )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Writes the string entry \fIvalue\fR into key \fIkey\fR. The \fIkey\fR is created if it doesn't exist. Any previous value is overwritten by \fIvalue\fR. If \fIvalue\fR is an empty string or a null string the key's value will be an empty string.
.PP
If an error occurs the settings are left unchanged and FALSE is returned; otherwise TRUE is returned.
.PP
See also readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), and removeEntry().
.SH "bool QSettings::writeEntry ( const QString & key, const QStringList & value )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Writes the string list entry \fIvalue\fR into key \fIkey\fR. The \fIkey\fR is created if it doesn't exist. Any previous value is overwritten by \fIvalue\fR.
.PP
If an error occurs the settings are left unchanged and FALSE is returned; otherwise returns TRUE.
.PP
See also readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), and removeEntry().
.SH "bool QSettings::writeEntry ( const QString & key, const QStringList & value, const QChar & separator )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
Writes the string list entry \fIvalue\fR into key \fIkey\fR. The \fIkey\fR is created if it doesn't exist. Any previous value is overwritten by \fIvalue\fR. The list is stored as a sequence of strings separated by \fIseparator\fR (using QStringList::join()), so none of the strings in the list should contain the separator. If the list is empty or null the key's value will be an empty string.
.PP
\fBWarning:\fR The list should not contain empty or null strings, as readListEntry() will use QStringList::split() to recreate the list. As the documentation states, QStringList::split() will omit empty strings from the list. Because of this, it is impossible to retrieve identical list data that is stored with this function. We recommend using the writeEntry() and readListEntry() overloads that do not take a \fIseparator\fR argument.
.PP
If an error occurs the settings are left unchanged and FALSE is returned; otherwise returns TRUE.
.PP
See also readListEntry(), readNumEntry(), readDoubleEntry(), readBoolEntry(), removeEntry(), and QStringList::join().

.SH "SEE ALSO"
.BR http://doc.trolltech.com/qsettings.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive Qt documentation is provided in HTML format; it is
located at $QTDIR/doc/html and can be read using Qt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech. 
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (qsettings.3qt) and the Qt
version (3.3.8).