File: qsettings.html

package info (click to toggle)
python-qt4 4.7.3-1%2Bsqueeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 28,504 kB
  • ctags: 4,680
  • sloc: python: 28,738; cpp: 8,897; sh: 245; xml: 243; makefile: 150
file content (597 lines) | stat: -rw-r--r-- 70,208 bytes parent folder | download
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
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QSettings Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QSettings Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QSettings class provides persistent platform-independent application settings. <a href="#details">More...</a></p>
<p>Inherits <a href="qobject.html">QObject</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qsettings.html#Format-enum">Format</a></b> { NativeFormat, IniFormat, InvalidFormat }</li><li><div class="fn" />enum <b><a href="qsettings.html#Scope-enum">Scope</a></b> { UserScope, SystemScope }</li><li><div class="fn" />enum <b><a href="qsettings.html#Status-enum">Status</a></b> { NoError, AccessError, FormatError }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qsettings.html#QSettings">__init__</a></b> (<i>self</i>, QString, QString&#160;<i>application</i>&#160;=&#160;QString(), QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qsettings.html#QSettings-2">__init__</a></b> (<i>self</i>, Scope, QString, QString&#160;<i>application</i>&#160;=&#160;QString(), QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qsettings.html#QSettings-3">__init__</a></b> (<i>self</i>, Format, Scope, QString, QString&#160;<i>application</i>&#160;=&#160;QString(), QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qsettings.html#QSettings-4">__init__</a></b> (<i>self</i>, QString, Format, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qsettings.html#QSettings-5">__init__</a></b> (<i>self</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" />QStringList <b><a href="qsettings.html#allKeys">allKeys</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qsettings.html#applicationName">applicationName</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qsettings.html#beginGroup">beginGroup</a></b> (<i>self</i>, QString)</li><li><div class="fn" />int <b><a href="qsettings.html#beginReadArray">beginReadArray</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qsettings.html#beginWriteArray">beginWriteArray</a></b> (<i>self</i>, QString, int&#160;<i>size</i>&#160;=&#160;-1)</li><li><div class="fn" />QStringList <b><a href="qsettings.html#childGroups">childGroups</a></b> (<i>self</i>)</li><li><div class="fn" />QStringList <b><a href="qsettings.html#childKeys">childKeys</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qsettings.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsettings.html#contains">contains</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qsettings.html#endArray">endArray</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qsettings.html#endGroup">endGroup</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsettings.html#event">event</a></b> (<i>self</i>, QEvent)</li><li><div class="fn" />bool <b><a href="qsettings.html#fallbacksEnabled">fallbacksEnabled</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qsettings.html#fileName">fileName</a></b> (<i>self</i>)</li><li><div class="fn" />Format <b><a href="qsettings.html#format">format</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qsettings.html#group">group</a></b> (<i>self</i>)</li><li><div class="fn" />QTextCodec <b><a href="qsettings.html#iniCodec">iniCodec</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsettings.html#isWritable">isWritable</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qsettings.html#organizationName">organizationName</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qsettings.html#remove">remove</a></b> (<i>self</i>, QString)</li><li><div class="fn" />Scope <b><a href="qsettings.html#scope">scope</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qsettings.html#setArrayIndex">setArrayIndex</a></b> (<i>self</i>, int)</li><li><div class="fn" /><b><a href="qsettings.html#setFallbacksEnabled">setFallbacksEnabled</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qsettings.html#setIniCodec">setIniCodec</a></b> (<i>self</i>, QTextCodec)</li><li><div class="fn" /><b><a href="qsettings.html#setIniCodec-2">setIniCodec</a></b> (<i>self</i>, str)</li><li><div class="fn" /><b><a href="qsettings.html#setValue">setValue</a></b> (<i>self</i>, QString, QVariant)</li><li><div class="fn" />Status <b><a href="qsettings.html#status">status</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qsettings.html#sync">sync</a></b> (<i>self</i>)</li><li><div class="fn" />QVariant <b><a href="qsettings.html#value">value</a></b> (<i>self</i>, QString, QVariant&#160;<i>defaultValue</i>&#160;=&#160;QVariant())</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />Format <b><a href="qsettings.html#defaultFormat">defaultFormat</a></b> ()</li><li><div class="fn" /><b><a href="qsettings.html#setDefaultFormat">setDefaultFormat</a></b> (Format)</li><li><div class="fn" /><b><a href="qsettings.html#setPath">setPath</a></b> (Format, Scope, QString)</li><li><div class="fn" /><b><a href="qsettings.html#setSystemIniPath">setSystemIniPath</a></b> (QString)</li><li><div class="fn" /><b><a href="qsettings.html#setUserIniPath">setUserIniPath</a></b> (QString)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QSettings class provides persistent platform-independent application settings.</p>
<p>Users normally expect an application to remember its settings (window sizes and positions, options, etc.) across sessions. This information is often stored in the system registry on Windows, and in XML preferences files on Mac OS X. On Unix systems, in the absence of a standard, many applications (including the KDE applications) use INI text files.</p>
<p>QSettings is an abstraction around these technologies, enabling you to save and restore application settings in a portable manner. It also supports <a href="qsettings.html#registerFormat">custom storage formats</a>.</p>
<p>QSettings's API is based on <a href="qvariant.html">QVariant</a>, allowing you to save most value-based types, such as <a href="qstring.html">QString</a>, <a href="qrect.html">QRect</a>, and <a href="qimage.html">QImage</a>, with the minimum of effort.</p>
<p>If all you need is a non-persistent memory-based structure, consider using <a href="qmap.html">QMap</a>&lt;<a href="qstring.html">QString</a>, <a href="qvariant.html">QVariant</a>&gt; instead.</p>
<ul><li><a href="#basic-usage">Basic Usage</a></li>
<li><a href="#qvariant-and-gui-types">QVariant and GUI Types</a></li>
<li><a href="#section-and-key-syntax">Section and Key Syntax</a></li>
<li><a href="#fallback-mechanism">Fallback Mechanism</a></li>
<li><a href="#restoring-the-state-of-a-gui-application">Restoring the State of a GUI Application</a></li>
<li><a href="#accessing-settings-from-multiple-threads-or-processes-simultaneously">Accessing Settings from Multiple Threads or Processes Simultaneously</a></li>
<li><a href="#platform-specific-notes">Platform-Specific Notes</a></li>
</ul>
<a name="basic-usage" />
<h3>Basic Usage</h3>
<p>When creating a QSettings object, you must pass the name of your company or organization as well as the name of your application. For example, if your product is called Star Runner and your company is called MySoft, you would construct the QSettings object as follows:</p>
<pre>     QSettings settings("MySoft", "Star Runner");</pre>
<p>QSettings objects can be created either on the stack or on the heap (i.e. using <tt>new</tt>). Constructing and destroying a QSettings object is very fast.</p>
<p>If you use QSettings from many places in your application, you might want to specify the organization name and the application name using <a href="qcoreapplication.html#organizationName-prop">QCoreApplication.setOrganizationName</a>() and <a href="qcoreapplication.html#applicationName-prop">QCoreApplication.setApplicationName</a>(), and then use the default QSettings constructor:</p>
<pre>     QCoreApplication.setOrganizationName("MySoft");
     QCoreApplication.setOrganizationDomain("mysoft.com");
     QCoreApplication.setApplicationName("Star Runner");
     ...
     QSettings settings;</pre>
<p>(Here, we also specify the organization's Internet domain. When the Internet domain is set, it is used on Mac OS X instead of the organization name, since Mac OS X applications conventionally use Internet domains to identify themselves. If no domain is set, a fake domain is derived from the organization name. See the <a href="#platform-specific-notes">Platform-Specific Notes</a> below for details.)</p>
<p>QSettings stores settings. Each setting consists of a <a href="qstring.html">QString</a> that specifies the setting's name (the <i>key</i>) and a <a href="qvariant.html">QVariant</a> that stores the data associated with the key. To write a setting, use <a href="qsettings.html#setValue">setValue</a>(). For example:</p>
<pre>     settings.setValue("editor/wrapMargin", 68);</pre>
<p>If there already exists a setting with the same key, the existing value is overwritten by the new value. For efficiency, the changes may not be saved to permanent storage immediately. (You can always call <a href="qsettings.html#sync">sync</a>() to commit your changes.)</p>
<p>You can get a setting's value back using <a href="qsettings.html#value">value</a>():</p>
<pre>     int margin = settings.value("editor/wrapMargin").toInt();</pre>
<p>If there is no setting with the specified name, QSettings returns a null <a href="qvariant.html">QVariant</a> (which can be converted to the integer 0). You can specify another default value by passing a second argument to <a href="qsettings.html#value">value</a>():</p>
<pre>     int margin = settings.value("editor/wrapMargin", 80).toInt();</pre>
<p>To test whether a given key exists, call <a href="qsettings.html#contains">contains</a>(). To remove the setting associated with a key, call <a href="qsettings.html#remove">remove</a>(). To obtain the list of all keys, call <a href="qsettings.html#allKeys">allKeys</a>(). To remove all keys, call <a href="qsettings.html#clear">clear</a>().</p>
<a name="qvariant-and-gui-types" />
<h3>QVariant and GUI Types</h3>
<p>Because <a href="qvariant.html">QVariant</a> is part of the <a href="qtcore.html">QtCore</a> library, it cannot provide conversion functions to data types such as <a href="qcolor.html">QColor</a>, <a href="qimage.html">QImage</a>, and <a href="qpixmap.html">QPixmap</a>, which are part of <a href="qtgui.html">QtGui</a>. In other words, there is no <tt>toColor()</tt>, <tt>toImage()</tt>, or <tt>toPixmap()</tt> functions in <a href="qvariant.html">QVariant</a>.</p>
<p>Instead, you can use the <a href="qvariant.html#value">QVariant.value</a>() or the <a href="qvariant.html#qVariantValue">qVariantValue</a>() template function. For example:</p>
<pre> QSettings settings("MySoft", "Star Runner");
 QColor color = settings.value("DataPump/bgcolor").value&lt;QColor&gt;();</pre>
<p>The inverse conversion (e.g., from <a href="qcolor.html">QColor</a> to <a href="qvariant.html">QVariant</a>) is automatic for all data types supported by <a href="qvariant.html">QVariant</a>, including GUI-related types:</p>
<pre> QSettings settings("MySoft", "Star Runner");
 QColor color = palette().background().color();
 settings.setValue("DataPump/bgcolor", color);</pre>
<p>Custom types registered using <a href="qmetatype.html#qRegisterMetaType">qRegisterMetaType</a>() and <a href="qmetatype.html#qRegisterMetaTypeStreamOperators">qRegisterMetaTypeStreamOperators</a>() can be stored using QSettings.</p>
<a name="section-and-key-syntax" />
<h3>Section and Key Syntax</h3>
<p>Setting keys can contain any Unicode characters. The Windows registry and INI files use case-insensitive keys, whereas the Carbon Preferences API on Mac OS X uses case-sensitive keys. To avoid portability problems, follow these simple rules:</p>
<ol type="1">
<li>Always refer to the same key using the same case. For example, if you refer to a key as "text fonts" in one place in your code, don't refer to it as "Text Fonts" somewhere else.</li>
<li>Avoid key names that are identical except for the case. For example, if you have a key called "<a href="designer-to-know.html#mainwindow">MainWindow</a>", don't try to save another key as "mainwindow".</li>
<li>Do not use slashes ('/' and '\') in section or key names; the backslash character is used to separate sub keys (see below). On windows '\' are converted by QSettings to '/', which makes them identical.</li>
</ol>
<p>You can form hierarchical keys using the '/' character as a separator, similar to Unix file paths. For example:</p>
<pre>     settings.setValue("mainwindow/size", win-&gt;size());
     settings.setValue("mainwindow/fullScreen", win-&gt;isFullScreen());
     settings.setValue("outputpanel/visible", panel-&gt;isVisible());</pre>
<p>If you want to save or restore many settings with the same prefix, you can specify the prefix using <a href="qsettings.html#beginGroup">beginGroup</a>() and call <a href="qsettings.html#endGroup">endGroup</a>() at the end. Here's the same example again, but this time using the group mechanism:</p>
<pre>     settings.beginGroup("mainwindow");
     settings.setValue("size", win-&gt;size());
     settings.setValue("fullScreen", win-&gt;isFullScreen());
     settings.endGroup();

     settings.beginGroup("outputpanel");
     settings.setValue("visible", panel-&gt;isVisible());
     settings.endGroup();</pre>
<p>If a group is set using <a href="qsettings.html#beginGroup">beginGroup</a>(), the behavior of most functions changes consequently. Groups can be set recursively.</p>
<p>In addition to groups, QSettings also supports an "array" concept. See <a href="qsettings.html#beginReadArray">beginReadArray</a>() and <a href="qsettings.html#beginWriteArray">beginWriteArray</a>() for details.</p>
<a name="fallback-mechanism" />
<h3>Fallback Mechanism</h3>
<p>Let's assume that you have created a QSettings object with the organization name MySoft and the application name Star Runner. When you look up a value, up to four locations are searched in that order:</p>
<ol type="1">
<li>a user-specific location for the Star Runner application</li>
<li>a user-specific location for all applications by MySoft</li>
<li>a system-wide location for the Star Runner application</li>
<li>a system-wide location for all applications by MySoft</li>
</ol>
<p>(See <a href="#platform-specific-notes">Platform-Specific Notes</a> below for information on what these locations are on the different platforms supported by Qt.)</p>
<p>If a key cannot be found in the first location, the search goes on in the second location, and so on. This enables you to store system-wide or organization-wide settings and to override them on a per-user or per-application basis. To turn off this mechanism, call setFallbacksEnabled(false).</p>
<p>Although keys from all four locations are available for reading, only the first file (the user-specific location for the application at hand) is accessible for writing. To write to any of the other files, omit the application name and/or specify <a href="qsettings.html#Scope-enum">QSettings.SystemScope</a> (as opposed to <a href="qsettings.html#Scope-enum">QSettings.UserScope</a>, the default).</p>
<p>Let's see with an example:</p>
<pre>     QSettings obj1("MySoft", "Star Runner");
     QSettings obj2("MySoft");
     QSettings obj3(QSettings.SystemScope, "MySoft", "Star Runner");
     QSettings obj4(QSettings.SystemScope, "MySoft");</pre>
<p>The table below summarizes which QSettings objects access which location. "<b>X</b>" means that the location is the main location associated to the QSettings object and is used both for reading and for writing; "o" means that the location is used as a fallback when reading.</p>
<p><table align="center" border="0" cellpadding="2" cellspacing="1" class="generic">
<thead><tr class="qt-style" valign="top"><th>Locations</th><th><tt>obj1</tt></th><th><tt>obj2</tt></th><th><tt>obj3</tt></th><th><tt>obj4</tt></th></tr></thead>
<tr class="odd" valign="top"><td>1. User, Application</td><td><b>X</b></td><td /><td /><td /></tr>
<tr class="even" valign="top"><td>2. User, Organization</td><td>o</td><td><b>X</b></td><td /><td /></tr>
<tr class="odd" valign="top"><td>3. System, Application</td><td>o</td><td /><td><b>X</b></td><td /></tr>
<tr class="even" valign="top"><td>4. System, Organization</td><td>o</td><td>o</td><td>o</td><td><b>X</b></td></tr>
</table></p>
<p>The beauty of this mechanism is that it works on all platforms supported by Qt and that it still gives you a lot of flexibility, without requiring you to specify any file names or registry paths.</p>
<p>If you want to use INI files on all platforms instead of the native API, you can pass <a href="qsettings.html#Format-enum">QSettings.IniFormat</a> as the first argument to the QSettings constructor, followed by the scope, the organization name, and the application name:</p>
<pre>     QSettings settings(QSettings.IniFormat, QSettings.UserScope,
                        "MySoft", "Star Runner");</pre>
<p>The <a href="tools-settingseditor.html">Settings Editor</a> example lets you experiment with different settings location and with fallbacks turned on or off.</p>
<a name="restoring-the-state-of-a-gui-application" />
<h3>Restoring the State of a GUI Application</h3>
<p>QSettings is often used to store the state of a GUI application. The following example illustrates how to use QSettings to save and restore the geometry of an application's main window.</p>
<pre> void MainWindow.writeSettings()
 {
     QSettings settings("Moose Soft", "Clipper");

     settings.beginGroup("MainWindow");
     settings.setValue("size", size());
     settings.setValue("pos", pos());
     settings.endGroup();
 }

 void MainWindow.readSettings()
 {
     QSettings settings("Moose Soft", "Clipper");

     settings.beginGroup("MainWindow");
     resize(settings.value("size", QSize(400, 400)).toSize());
     move(settings.value("pos", QPoint(200, 200)).toPoint());
     settings.endGroup();
 }</pre>
<p>See <a href="application-windows.html#window-geometry">Window Geometry</a> for a discussion on why it is better to call <a href="qwidget.html#size-prop">QWidget.resize</a>() and <a href="qwidget.html#pos-prop">QWidget.move</a>() rather than <a href="qwidget.html#geometry-prop">QWidget.setGeometry</a>() to restore a window's geometry.</p>
<p>The <tt>readSettings()</tt> and <tt>writeSettings()</tt> functions must be called from the main window's constructor and close event handler as follows:</p>
<pre> MainWindow.MainWindow()
 {
     ...
     readSettings();
 }

 void MainWindow.closeEvent(QCloseEvent *event)
 {
     if (userReallyWantsToQuit()) {
         writeSettings();
         event-&gt;accept();
     } else {
         event-&gt;ignore();
     }
 }</pre>
<p>See the <a href="mainwindows-application.html">Application</a> example for a self-contained example that uses QSettings.</p>
<a name="accessing-settings-from-multiple-threads-or-processes-simultaneously" />
<h3>Accessing Settings from Multiple Threads or Processes Simultaneously</h3>
<p>QSettings is <a href="threads-reentrancy.html#reentrant">reentrant</a>. This means that you can use distinct QSettings object in different threads simultaneously. This guarantee stands even when the QSettings objects refer to the same files on disk (or to the same entries in the system registry). If a setting is modified through one QSettings object, the change will immediately be visible in any other QSettings objects that operate on the same location and that live in the same process.</p>
<p>QSettings can safely be used from different processes (which can be different instances of your application running at the same time or different applications altogether) to read and write to the same system locations. It uses advisory file locking and a smart merging algorithm to ensure data integrity. Changes performed by another process aren't visible in the current process until <a href="qsettings.html#sync">sync</a>() is called.</p>
<a name="platform-specific-notes" />
<h3>Platform-Specific Notes</h3>
<a name="locations-where-application-settings-are-stored" />
<h4>Locations Where Application Settings Are Stored</h4>
<p>As mentioned in the <a href="#fallback-mechanism">Fallback Mechanism</a> section, QSettings stores settings for an application in up to four locations, depending on whether the settings are user-specific or system-wide and whether the settings are application-specific or organization-wide. For simplicity, we're assuming the organization is called MySoft and the application is called Star Runner.</p>
<p>On Unix systems, if the file format is <a href="qsettings.html#Format-enum">NativeFormat</a>, the following files are used by default:</p>
<ol type="1">
<li><tt>$HOME/.config/MySoft/Star Runner.conf</tt> (Qt for Embedded Linux: <tt>$HOME/Settings/MySoft/Star Runner.conf</tt>)</li>
<li><tt>$HOME/.config/MySoft.conf</tt> (Qt for Embedded Linux: <tt>$HOME/Settings/MySoft.conf</tt>)</li>
<li><tt>/etc/xdg/MySoft/Star Runner.conf</tt></li>
<li><tt>/etc/xdg/MySoft.conf</tt></li>
</ol>
<p>On Mac OS X versions 10.2 and 10.3, these files are used by default:</p>
<ol type="1">
<li><tt>$HOME/Library/Preferences/com.MySoft.Star Runner.plist</tt></li>
<li><tt>$HOME/Library/Preferences/com.MySoft.plist</tt></li>
<li><tt>/Library/Preferences/com.MySoft.Star Runner.plist</tt></li>
<li><tt>/Library/Preferences/com.MySoft.plist</tt></li>
</ol>
<p>On Windows, <a href="qsettings.html#Format-enum">NativeFormat</a> settings are stored in the following registry paths:</p>
<ol type="1">
<li><tt>HKEY_CURRENT_USER\Software\MySoft\Star Runner</tt></li>
<li><tt>HKEY_CURRENT_USER\Software\MySoft</tt></li>
<li><tt>HKEY_LOCAL_MACHINE\Software\MySoft\Star Runner</tt></li>
<li><tt>HKEY_LOCAL_MACHINE\Software\MySoft</tt></li>
</ol>
<p><b>Note:</b> On Windows, for 32-bit programs running in WOW64 mode, settings are stored in the following registry path: <tt>HKEY_LOCAL_MACHINE\Software\WOW6432node</tt>.</p>
<p>If the file format is <a href="qsettings.html#Format-enum">IniFormat</a>, the following files are used on Unix and Mac OS X:</p>
<ol type="1">
<li><tt>$HOME/.config/MySoft/Star Runner.ini</tt> (Qt for Embedded Linux: <tt>$HOME/Settings/MySoft/Star Runner.ini</tt>)</li>
<li><tt>$HOME/.config/MySoft.ini</tt> (Qt for Embedded Linux: <tt>$HOME/Settings/MySoft.ini</tt>)</li>
<li><tt>/etc/xdg/MySoft/Star Runner.ini</tt></li>
<li><tt>/etc/xdg/MySoft.ini</tt></li>
</ol>
<p>On Windows, the following files are used:</p>
<ol type="1">
<li><tt>%APPDATA%\MySoft\Star Runner.ini</tt></li>
<li><tt>%APPDATA%\MySoft.ini</tt></li>
<li><tt>%COMMON_APPDATA%\MySoft\Star Runner.ini</tt></li>
<li><tt>%COMMON_APPDATA%\MySoft.ini</tt></li>
</ol>
<p>The <tt>%APPDATA%</tt> path is usually <tt>C:\Documents and Settings\<i>User Name</i>\Application Data</tt>; the <tt>%COMMON_APPDATA%</tt> path is usually <tt>C:\Documents and Settings\All Users\Application Data</tt>.</p>
<p>The paths for the <tt>.ini</tt> and <tt>.conf</tt> files can be changed using <a href="qsettings.html#setPath">setPath</a>(). On Unix and Mac OS X, the user can override them by by setting the <tt>XDG_CONFIG_HOME</tt> environment variable; see <a href="qsettings.html#setPath">setPath</a>() for details.</p>
<a name="accessing-ini-and-plist-files-directly" />
<h4>Accessing INI and .plist Files Directly</h4>
<p>Sometimes you do want to access settings stored in a specific file or registry path. On all platforms, if you want to read an INI file directly, you can use the QSettings constructor that takes a file name as first argument and pass <a href="qsettings.html#Format-enum">QSettings.IniFormat</a> as second argument. For example:</p>
<pre> QSettings settings("/home/petra/misc/myapp.ini",
                    QSettings.IniFormat);</pre>
<p>You can then use the QSettings object to read and write settings in the file.</p>
<p>On Mac OS X, you can access XML-based <tt>.plist</tt> files by passing <a href="qsettings.html#Format-enum">QSettings.NativeFormat</a> as second argument. For example:</p>
<pre> QSettings settings("/Users/petra/misc/myapp.plist",
                    QSettings.NativeFormat);</pre>
<a name="accessing-the-windows-registry-directly" />
<h4>Accessing the Windows Registry Directly</h4>
<p>On Windows, QSettings lets you access settings that have been written with QSettings (or settings in a supported format, e.g., string data) in the system registry. This is done by constructing a QSettings object with a path in the registry and <a href="qsettings.html#Format-enum">QSettings.NativeFormat</a>.</p>
<p>For example:</p>
<pre> QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Office",
                    QSettings.NativeFormat);</pre>
<p>All the registry entries that appear under the specified path can be read or written through the QSettings object as usual (using forward slashes instead of backslashes). For example:</p>
<pre> settings.setValue("11.0/Outlook/Security/DontTrustInstalledFiles", 0);</pre>
<p>Note that the backslash character is, as mentioned, used by QSettings to separate subkeys. As a result, you cannot read or write windows registry entries that contain slashes or backslashes; you should use a native windows API if you need to do so.</p>
<a name="accessing-common-registry-settings-on-windows" />
<h4>Accessing Common Registry Settings on Windows</h4>
<p>On Windows, it is possible for a key to have both a value and subkeys. Its default value is accessed by using "Default" or "." in place of a subkey:</p>
<pre> settings.setValue("HKEY_CURRENT_USER\\MySoft\\Star Runner\\Galaxy", "Milkyway");
 settings.setValue("HKEY_CURRENT_USER\\MySoft\\Star Runner\\Galaxy\\Sun", "OurStar");
 settings.value("HKEY_CURRENT_USER\\MySoft\\Star Runner\\Galaxy\\Default"); <span class="comment">// returns "Milkyway"</span></pre>
<p>On other platforms than Windows, "Default" and "." would be treated as regular subkeys.</p>
<a name="platform-limitations" />
<h4>Platform Limitations</h4>
<p>While QSettings attempts to smooth over the differences between the different supported platforms, there are still a few differences that you should be aware of when porting your application:</p>
<ul>
<li>The Windows system registry has the following limitations: A subkey may not exceed 255 characters, an entry's value may not exceed 16,383 characters, and all the values of a key may not exceed 65,535 characters. One way to work around these limitations is to store the settings using the <a href="qsettings.html#Format-enum">IniFormat</a> instead of the <a href="qsettings.html#Format-enum">NativeFormat</a>.</li>
<li>On Mac OS X, <a href="qsettings.html#allKeys">allKeys</a>() will return some extra keys for global settings that apply to all applications. These keys can be read using <a href="qsettings.html#value">value</a>() but cannot be changed, only shadowed. Calling setFallbacksEnabled(false) will hide these global settings.</li>
<li>On Mac OS X, the CFPreferences API used by QSettings expects Internet domain names rather than organization names. To provide a uniform API, QSettings derives a fake domain name from the organization name (unless the organization name already is a domain name, e.g. OpenOffice.org). The algorithm appends ".com" to the company name and replaces spaces and other illegal characters with hyphens. If you want to specify a different domain name, call <a href="qcoreapplication.html#organizationDomain-prop">QCoreApplication.setOrganizationDomain</a>(), <a href="qcoreapplication.html#organizationName-prop">QCoreApplication.setOrganizationName</a>(), and <a href="qcoreapplication.html#applicationName-prop">QCoreApplication.setApplicationName</a>() in your <tt>main()</tt> function and then use the default QSettings constructor. Another solution is to use preprocessor directives, for example:<pre> #ifdef Q_WS_MAC
     QSettings settings("grenoullelogique.fr", "Squash");
 #else
     QSettings settings("Grenoulle Logique", "Squash");
 #endif</pre>
</li>
<li>On Unix and Mac OS X systems, the advisory file locking is disabled if NFS (or AutoFS or CacheFS) is detected to work around a bug in the NFS fcntl() implementation, which hangs forever if statd or lockd aren't running. Also, the locking isn't performed when accessing <tt>.plist</tt> files.</li>
</ul>
<p>See also <a href="qvariant.html">QVariant</a>, <a href="qsessionmanager.html">QSessionManager</a>, <a href="tools-settingseditor.html">Settings Editor Example</a>, and <a href="mainwindows-application.html">Application Example</a>.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="Format-enum" />QSettings.Format</h3><p>This enum type specifies the storage format used by <a href="qsettings.html">QSettings</a>.</p>
<p><table border="1" cellpadding="2" cellspacing="1" class="valuelist" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QSettings.NativeFormat</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">Store the settings using the most appropriate storage format for the platform. On Windows, this means the system registry; on Mac OS X, this means the CFPreferences API; on Unix, this means textual configuration files in INI format.</td></tr>
<tr><td valign="top"><tt>QSettings.IniFormat</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">Store the settings in INI files.</td></tr>
<tr><td valign="top"><tt>QSettings.InvalidFormat</tt></td><td align="center" valign="top"><tt>16</tt></td><td valign="top">Special value returned by <a href="qsettings.html#registerFormat">registerFormat</a>().</td></tr>
</table></p>
<p>On Unix, NativeFormat and IniFormat mean the same thing, except that the file extension is different (<tt>.conf</tt> for NativeFormat, <tt>.ini</tt> for IniFormat).</p>
<p>The INI file format is a Windows file format that Qt supports on all platforms. In the absence of an INI standard, we try to follow what Microsoft does, with the following exceptions:</p>
<ul>
<li>If you store types that <a href="qvariant.html">QVariant</a> can't convert to <a href="qstring.html">QString</a> (e.g., <a href="qpoint.html">QPoint</a>, <a href="qrect.html">QRect</a>, and <a href="qsize.html">QSize</a>), Qt uses an <tt>@</tt>-based syntax to encode the type. For example:<pre> pos = @Point(100 100)</pre>
<p>To minimize compatibility issues, any <tt>@</tt> that doesn't appear at the first position in the value or that isn't followed by a Qt type (<tt>Point</tt>, <tt>Rect</tt>, <tt>Size</tt>, etc.) is treated as a normal character.</p>
</li>
<li>Although backslash is a special character in INI files, most Windows applications don't escape backslashes (<tt>\</tt>) in file paths:<pre> windir = C:\Windows</pre>
<p><a href="qsettings.html">QSettings</a> always treats backslash as a special character and provides no API for reading or writing such entries.</p>
</li>
<li>The INI file format has severe restrictions on the syntax of a key. Qt works around this by using <tt>%</tt> as an escape character in keys. In addition, if you save a top-level setting (a key with no slashes in it, e.g., "someKey"), it will appear in the INI file's "General" section. To avoid overwriting other keys, if you save something using the a key such as "General/someKey", the key will be located in the "%General" section, <i>not</i> in the "General" section.</li>
<li>Following the philosophy that we should be liberal in what we accept and conservative in what we generate, <a href="qsettings.html">QSettings</a> will accept Latin-1 encoded INI files, but generate pure ASCII files, where non-ASCII values are encoded using standard INI escape sequences. To make the INI files more readable (but potentially less compatible), call <a href="qsettings.html#setIniCodec">setIniCodec</a>().</li>
</ul>
<p>See also <a href="qsettings.html#registerFormat">registerFormat</a>() and <a href="qsettings.html#setPath">setPath</a>().</p>
<a name="//apple_ref/cpp/tdef/QSettings/ReadFunc" />
<h3 class="fn"><a name="Scope-enum" />QSettings.Scope</h3><p>This enum specifies whether settings are user-specific or shared by all users of the same system.</p>
<p><table border="1" cellpadding="2" cellspacing="1" class="valuelist" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QSettings.UserScope</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">Store settings in a location specific to the current user (e.g., in the user's home directory).</td></tr>
<tr><td valign="top"><tt>QSettings.SystemScope</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">Store settings in a global location, so that all users on the same machine access the same set of settings.</td></tr>
</table></p>
<p>See also <a href="qsettings.html#setPath">setPath</a>().</p>
<a name="//apple_ref/cpp/tdef/QSettings/SettingsMap" />
<h3 class="fn"><a name="Status-enum" />QSettings.Status</h3><p>The following status values are possible:</p>
<p><table border="1" cellpadding="2" cellspacing="1" class="valuelist" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QSettings.NoError</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">No error occurred.</td></tr>
<tr><td valign="top"><tt>QSettings.AccessError</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">An access error occurred (e.g. trying to write to a read-only file).</td></tr>
<tr><td valign="top"><tt>QSettings.FormatError</tt></td><td align="center" valign="top"><tt>2</tt></td><td valign="top">A format error occurred (e.g. loading a malformed INI file).</td></tr>
</table></p>
<p>See also <a href="qsettings.html#status">status</a>().</p>
<a name="//apple_ref/cpp/tdef/QSettings/WriteFunc" />
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QSettings" />QSettings.__init__ (<i>self</i>, QString, QString&#160;<i>application</i>&#160;=&#160;QString(), <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a <a href="qsettings.html">QSettings</a> object for accessing settings of the application called <i>application</i> from the organization called <i>organization</i>, and with parent <i>parent</i>.</p>
<p>Example:</p>
<pre> QSettings settings("Moose Tech", "Facturo-Pro");</pre>
<p>The scope is set to <a href="qsettings.html#Scope-enum">QSettings.UserScope</a>, and the format is set to <a href="qsettings.html#Format-enum">QSettings.NativeFormat</a> (i.e. calling <a href="qsettings.html#setDefaultFormat">setDefaultFormat</a>() before calling this constructor has no effect).</p>
<p>See also <a href="qsettings.html#setDefaultFormat">setDefaultFormat</a>() and <a href="qsettings.html#fallback-mechanism">Fallback Mechanism</a>.</p>
<h3 class="fn"><a name="QSettings-2" />QSettings.__init__ (<i>self</i>, <a href="qsettings.html#Scope-enum">Scope</a>, QString, QString&#160;<i>application</i>&#160;=&#160;QString(), <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a <a href="qsettings.html">QSettings</a> object for accessing settings of the application called <i>application</i> from the organization called <i>organization</i>, and with parent <i>parent</i>.</p>
<p>If <i>scope</i> is <a href="qsettings.html#Scope-enum">QSettings.UserScope</a>, the <a href="qsettings.html">QSettings</a> object searches user-specific settings first, before it searches system-wide settings as a fallback. If <i>scope</i> is <a href="qsettings.html#Scope-enum">QSettings.SystemScope</a>, the <a href="qsettings.html">QSettings</a> object ignores user-specific settings and provides access to system-wide settings.</p>
<p>The storage format is set to <a href="qsettings.html#Format-enum">QSettings.NativeFormat</a> (i.e. calling <a href="qsettings.html#setDefaultFormat">setDefaultFormat</a>() before calling this constructor has no effect).</p>
<p>If no application name is given, the <a href="qsettings.html">QSettings</a> object will only access the organization-wide <a href="qsettings.html#fallback-mechanism">locations</a>.</p>
<p>See also <a href="qsettings.html#setDefaultFormat">setDefaultFormat</a>().</p>
<h3 class="fn"><a name="QSettings-3" />QSettings.__init__ (<i>self</i>, <a href="qsettings.html#Format-enum">Format</a>, <a href="qsettings.html#Scope-enum">Scope</a>, QString, QString&#160;<i>application</i>&#160;=&#160;QString(), <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a <a href="qsettings.html">QSettings</a> object for accessing settings of the application called <i>application</i> from the organization called <i>organization</i>, and with parent <i>parent</i>.</p>
<p>If <i>scope</i> is <a href="qsettings.html#Scope-enum">QSettings.UserScope</a>, the <a href="qsettings.html">QSettings</a> object searches user-specific settings first, before it searches system-wide settings as a fallback. If <i>scope</i> is <a href="qsettings.html#Scope-enum">QSettings.SystemScope</a>, the <a href="qsettings.html">QSettings</a> object ignores user-specific settings and provides access to system-wide settings.</p>
<p>If <i>format</i> is <a href="qsettings.html#Format-enum">QSettings.NativeFormat</a>, the native API is used for storing settings. If <i>format</i> is <a href="qsettings.html#Format-enum">QSettings.IniFormat</a>, the INI format is used.</p>
<p>If no application name is given, the <a href="qsettings.html">QSettings</a> object will only access the organization-wide <a href="qsettings.html#fallback-mechanism">locations</a>.</p>
<h3 class="fn"><a name="QSettings-4" />QSettings.__init__ (<i>self</i>, QString, <a href="qsettings.html#Format-enum">Format</a>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a <a href="qsettings.html">QSettings</a> object for accessing the settings stored in the file called <i>fileName</i>, with parent <i>parent</i>. If the file doesn't already exist, it is created.</p>
<p>If <i>format</i> is <a href="qsettings.html#Format-enum">QSettings.NativeFormat</a>, the meaning of <i>fileName</i> depends on the platform. On Unix, <i>fileName</i> is the name of an INI file. On Mac OS X, <i>fileName</i> is the name of a <tt>.plist</tt> file. On Windows, <i>fileName</i> is a path in the system registry.</p>
<p>If <i>format</i> is <a href="qsettings.html#Format-enum">QSettings.IniFormat</a>, <i>fileName</i> is the name of an INI file.</p>
<p><b>Warning:</b> This function is provided for convenience. It works well for accessing INI or <tt>.plist</tt> files generated by Qt, but might fail on some syntaxes found in such files originated by other programs. In particular, be aware of the following limitations:</p>
<ul>
<li><a href="qsettings.html">QSettings</a> provides no way of reading INI "path" entries, i.e., entries with unescaped slash characters. (This is because these entries are ambiguous and cannot be resolved automatically.)</li>
<li>In INI files, <a href="qsettings.html">QSettings</a> uses the <tt>@</tt> character as a metacharacter in some contexts, to encode Qt-specific data types (e.g., <tt>@Rect</tt>), and might therefore misinterpret it when it occurs in pure INI files.</li>
</ul>
<p>See also <a href="qsettings.html#fileName">fileName</a>().</p>
<h3 class="fn"><a name="QSettings-5" />QSettings.__init__ (<i>self</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a <a href="qsettings.html">QSettings</a> object for accessing settings of the application and organization set previously with a call to <a href="qcoreapplication.html#organizationName-prop">QCoreApplication.setOrganizationName</a>(), <a href="qcoreapplication.html#organizationDomain-prop">QCoreApplication.setOrganizationDomain</a>(), and <a href="qcoreapplication.html#applicationName-prop">QCoreApplication.setApplicationName</a>().</p>
<p>The scope is <a href="qsettings.html#Scope-enum">QSettings.UserScope</a> and the format is <a href="qsettings.html#defaultFormat">defaultFormat</a>() (<a href="qsettings.html#Format-enum">QSettings.NativeFormat</a> by default). Use <a href="qsettings.html#setDefaultFormat">setDefaultFormat</a>() before calling this constructor to change the default format used by this constructor.</p>
<p>The code</p>
<pre> QSettings settings("Moose Soft", "Facturo-Pro");</pre>
<p>is equivalent to</p>
<pre> QCoreApplication.setOrganizationName("Moose Soft");
 QCoreApplication.setApplicationName("Facturo-Pro");
 QSettings settings;</pre>
<p>If <a href="qcoreapplication.html#organizationName-prop">QCoreApplication.setOrganizationName</a>() and <a href="qcoreapplication.html#applicationName-prop">QCoreApplication.setApplicationName</a>() has not been previously called, the <a href="qsettings.html">QSettings</a> object will not be able to read or write any settings, and <a href="qsettings.html#status">status</a>() will return <a href="qsettings.html#Status-enum">AccessError</a>.</p>
<p>On Mac OS X, if both a name and an Internet domain are specified for the organization, the domain is preferred over the name. On other platforms, the name is preferred over the domain.</p>
<p>See also <a href="qcoreapplication.html#organizationName-prop">QCoreApplication.setOrganizationName</a>(), <a href="qcoreapplication.html#organizationDomain-prop">QCoreApplication.setOrganizationDomain</a>(), <a href="qcoreapplication.html#applicationName-prop">QCoreApplication.setApplicationName</a>(), and <a href="qsettings.html#setDefaultFormat">setDefaultFormat</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/~QSettings" />
<h3 class="fn"><a name="allKeys" />QStringList QSettings.allKeys (<i>self</i>)</h3><p>Returns a list of all keys, including subkeys, that can be read using the <a href="qsettings.html">QSettings</a> object.</p>
<p>Example:</p>
<pre> QSettings settings;
 settings.setValue("fridge/color", Qt.white);
 settings.setValue("fridge/size", QSize(32, 96));
 settings.setValue("sofa", true);
 settings.setValue("tv", false);

 QStringList keys = settings.allKeys();
<span class="comment"> // keys: ["fridge/color", "fridge/size", "sofa", "tv"]</span></pre>
<p>If a group is set using <a href="qsettings.html#beginGroup">beginGroup</a>(), only the keys in the group are returned, without the group prefix:</p>
<pre> settings.beginGroup("fridge");
 keys = settings.allKeys();
<span class="comment"> // keys: ["color", "size"]</span></pre>
<p>See also <a href="qsettings.html#childGroups">childGroups</a>() and <a href="qsettings.html#childKeys">childKeys</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/applicationName" />
<h3 class="fn"><a name="applicationName" />QString QSettings.applicationName (<i>self</i>)</h3><p>Returns the application name used for storing the settings.</p>
<p>This function was introduced in Qt 4.4.</p>
<p>See also <a href="qcoreapplication.html#applicationName-prop">QCoreApplication.applicationName</a>(), <a href="qsettings.html#format">format</a>(), <a href="qsettings.html#scope">scope</a>(), and <a href="qsettings.html#organizationName">organizationName</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/beginGroup" />
<h3 class="fn"><a name="beginGroup" />QSettings.beginGroup (<i>self</i>, QString)</h3><p>Appends <i>prefix</i> to the current group.</p>
<p>The current group is automatically prepended to all keys specified to <a href="qsettings.html">QSettings</a>. In addition, query functions such as <a href="qsettings.html#childGroups">childGroups</a>(), <a href="qsettings.html#childKeys">childKeys</a>(), and <a href="qsettings.html#allKeys">allKeys</a>() are based on the group. By default, no group is set.</p>
<p>Groups are useful to avoid typing in the same setting paths over and over. For example:</p>
<pre> settings.beginGroup("mainwindow");
 settings.setValue("size", win-&gt;size());
 settings.setValue("fullScreen", win-&gt;isFullScreen());
 settings.endGroup();

 settings.beginGroup("outputpanel");
 settings.setValue("visible", panel-&gt;isVisible());
 settings.endGroup();</pre>
<p>This will set the value of three settings:</p>
<ul>
<li><tt>mainwindow/size</tt></li>
<li><tt>mainwindow/fullScreen</tt></li>
<li><tt>outputpanel/visible</tt></li>
</ul>
<p>Call <a href="qsettings.html#endGroup">endGroup</a>() to reset the current group to what it was before the corresponding beginGroup() call. Groups can be nested.</p>
<p>See also <a href="qsettings.html#endGroup">endGroup</a>() and <a href="qsettings.html#group">group</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/beginReadArray" />
<h3 class="fn"><a name="beginReadArray" />int QSettings.beginReadArray (<i>self</i>, QString)</h3><p>Adds <i>prefix</i> to the current group and starts reading from an array. Returns the size of the array.</p>
<p>Example:</p>
<pre> struct Login {
     QString userName;
     QString password;
 };
 QList&lt;Login&gt; logins;
 ...

 QSettings settings;
 int size = settings.beginReadArray("logins");
 for (int i = 0; i &lt; size; ++i) {
     settings.setArrayIndex(i);
     Login login;
     login.userName = settings.value("userName").toString();
     login.password = settings.value("password").toString();
     logins.append(login);
 }
 settings.endArray();</pre>
<p>Use <a href="qsettings.html#beginWriteArray">beginWriteArray</a>() to write the array in the first place.</p>
<p>See also <a href="qsettings.html#beginWriteArray">beginWriteArray</a>(), <a href="qsettings.html#endArray">endArray</a>(), and <a href="qsettings.html#setArrayIndex">setArrayIndex</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/beginWriteArray" />
<h3 class="fn"><a name="beginWriteArray" />QSettings.beginWriteArray (<i>self</i>, QString, int&#160;<i>size</i>&#160;=&#160;-1)</h3><p>Adds <i>prefix</i> to the current group and starts writing an array of size <i>size</i>. If <i>size</i> is -1 (the default), it is automatically determined based on the indexes of the entries written.</p>
<p>If you have many occurrences of a certain set of keys, you can use arrays to make your life easier. For example, let's suppose that you want to save a variable-length list of user names and passwords. You could then write:</p>
<pre> struct Login {
     QString userName;
     QString password;
 };
 QList&lt;Login&gt; logins;
 ...

 QSettings settings;
 settings.beginWriteArray("logins");
 for (int i = 0; i &lt; logins.size(); ++i) {
     settings.setArrayIndex(i);
     settings.setValue("userName", list.at(i).userName);
     settings.setValue("password", list.at(i).password);
 }
 settings.endArray();</pre>
<p>The generated keys will have the form</p>
<ul>
<li><tt>logins/size</tt></li>
<li><tt>logins/1/userName</tt></li>
<li><tt>logins/1/password</tt></li>
<li><tt>logins/2/userName</tt></li>
<li><tt>logins/2/password</tt></li>
<li><tt>logins/3/userName</tt></li>
<li><tt>logins/3/password</tt></li>
<li>...</li>
</ul>
<p>To read back an array, use <a href="qsettings.html#beginReadArray">beginReadArray</a>().</p>
<p>See also <a href="qsettings.html#beginReadArray">beginReadArray</a>(), <a href="qsettings.html#endArray">endArray</a>(), and <a href="qsettings.html#setArrayIndex">setArrayIndex</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/childGroups" />
<h3 class="fn"><a name="childGroups" />QStringList QSettings.childGroups (<i>self</i>)</h3><p>Returns a list of all key top-level groups that contain keys that can be read using the <a href="qsettings.html">QSettings</a> object.</p>
<p>Example:</p>
<pre> QSettings settings;
 settings.setValue("fridge/color", Qt.white);
 settings.setValue("fridge/size", QSize(32, 96));
 settings.setValue("sofa", true);
 settings.setValue("tv", false);

 QStringList groups = settings.childGroups();
<span class="comment"> // group: ["fridge"]</span></pre>
<p>If a group is set using <a href="qsettings.html#beginGroup">beginGroup</a>(), the first-level keys in that group are returned, without the group prefix.</p>
<pre> settings.beginGroup("fridge");
 groups = settings.childGroups();
<span class="comment"> // groups: []</span></pre>
<p>You can navigate through the entire setting hierarchy using <a href="qsettings.html#childKeys">childKeys</a>() and childGroups() recursively.</p>
<p>See also <a href="qsettings.html#childKeys">childKeys</a>() and <a href="qsettings.html#allKeys">allKeys</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/childKeys" />
<h3 class="fn"><a name="childKeys" />QStringList QSettings.childKeys (<i>self</i>)</h3><p>Returns a list of all top-level keys that can be read using the <a href="qsettings.html">QSettings</a> object.</p>
<p>Example:</p>
<pre> QSettings settings;
 settings.setValue("fridge/color", Qt.white);
 settings.setValue("fridge/size", QSize(32, 96));
 settings.setValue("sofa", true);
 settings.setValue("tv", false);

 QStringList keys = settings.childKeys();
<span class="comment"> // keys: ["sofa", "tv"]</span></pre>
<p>If a group is set using <a href="qsettings.html#beginGroup">beginGroup</a>(), the top-level keys in that group are returned, without the group prefix:</p>
<pre> settings.beginGroup("fridge");
 keys = settings.childKeys();
<span class="comment"> // keys: ["color", "size"]</span></pre>
<p>You can navigate through the entire setting hierarchy using childKeys() and <a href="qsettings.html#childGroups">childGroups</a>() recursively.</p>
<p>See also <a href="qsettings.html#childGroups">childGroups</a>() and <a href="qsettings.html#allKeys">allKeys</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/clear" />
<h3 class="fn"><a name="clear" />QSettings.clear (<i>self</i>)</h3><p>Removes all entries in the primary location associated to this <a href="qsettings.html">QSettings</a> object.</p>
<p>Entries in fallback locations are not removed.</p>
<p>If you only want to remove the entries in the current <a href="qsettings.html#group">group</a>(), use remove("") instead.</p>
<p>See also <a href="qsettings.html#remove">remove</a>() and <a href="qsettings.html#setFallbacksEnabled">setFallbacksEnabled</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/contains" />
<h3 class="fn"><a name="contains" />bool QSettings.contains (<i>self</i>, QString)</h3><p>Returns true if there exists a setting called <i>key</i>; returns false otherwise.</p>
<p>If a group is set using <a href="qsettings.html#beginGroup">beginGroup</a>(), <i>key</i> is taken to be relative to that group.</p>
<p>Note that the Windows registry and INI files use case-insensitive keys, whereas the Carbon Preferences API on Mac OS X uses case-sensitive keys. To avoid portability problems, see the <a href="qsettings.html#section-and-key-syntax">Section and Key Syntax</a> rules.</p>
<p>See also <a href="qsettings.html#value">value</a>() and <a href="qsettings.html#setValue">setValue</a>().</p>
<a name="//apple_ref/cpp/clm/QSettings/defaultFormat" />
<h3 class="fn"><a name="defaultFormat" /><a href="qsettings.html#Format-enum">Format</a> QSettings.defaultFormat ()</h3><p>Returns default file format used for storing settings for the <a href="qsettings.html">QSettings</a>(<a href="qobject.html">QObject</a> *) constructor. If no default format is set, <a href="qsettings.html#Format-enum">QSettings.NativeFormat</a> is used.</p>
<p>This function was introduced in Qt 4.4.</p>
<p>See also <a href="qsettings.html#setDefaultFormat">setDefaultFormat</a>() and <a href="qsettings.html#format">format</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/endArray" />
<h3 class="fn"><a name="endArray" />QSettings.endArray (<i>self</i>)</h3><p>Closes the array that was started using <a href="qsettings.html#beginReadArray">beginReadArray</a>() or <a href="qsettings.html#beginWriteArray">beginWriteArray</a>().</p>
<p>See also <a href="qsettings.html#beginReadArray">beginReadArray</a>() and <a href="qsettings.html#beginWriteArray">beginWriteArray</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/endGroup" />
<h3 class="fn"><a name="endGroup" />QSettings.endGroup (<i>self</i>)</h3><p>Resets the group to what it was before the corresponding <a href="qsettings.html#beginGroup">beginGroup</a>() call.</p>
<p>Example:</p>
<pre> settings.beginGroup("alpha");
<span class="comment"> // settings.group() == "alpha"</span>

 settings.beginGroup("beta");
<span class="comment"> // settings.group() == "alpha/beta"</span>

 settings.endGroup();
<span class="comment"> // settings.group() == "alpha"</span>

 settings.endGroup();
<span class="comment"> // settings.group() == ""</span></pre>
<p>See also <a href="qsettings.html#beginGroup">beginGroup</a>() and <a href="qsettings.html#group">group</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/event" />
<h3 class="fn"><a name="event" />bool QSettings.event (<i>self</i>, <a href="qevent.html">QEvent</a>)</h3><p>Reimplemented from <a href="qobject.html#event">QObject.event</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/fallbacksEnabled" />
<h3 class="fn"><a name="fallbacksEnabled" />bool QSettings.fallbacksEnabled (<i>self</i>)</h3><p>Returns true if fallbacks are enabled; returns false otherwise.</p>
<p>By default, fallbacks are enabled.</p>
<p>See also <a href="qsettings.html#setFallbacksEnabled">setFallbacksEnabled</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/fileName" />
<h3 class="fn"><a name="fileName" />QString QSettings.fileName (<i>self</i>)</h3><p>Returns the path where settings written using this <a href="qsettings.html">QSettings</a> object are stored.</p>
<p>On Windows, if the format is <a href="qsettings.html#Format-enum">QSettings.NativeFormat</a>, the return value is a system registry path, not a file path.</p>
<p>See also <a href="qsettings.html#isWritable">isWritable</a>() and <a href="qsettings.html#format">format</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/format" />
<h3 class="fn"><a name="format" /><a href="qsettings.html#Format-enum">Format</a> QSettings.format (<i>self</i>)</h3><p>Returns the format used for storing the settings.</p>
<p>This function was introduced in Qt 4.4.</p>
<p>See also <a href="qsettings.html#defaultFormat">defaultFormat</a>(), <a href="qsettings.html#fileName">fileName</a>(), <a href="qsettings.html#scope">scope</a>(), <a href="qsettings.html#organizationName">organizationName</a>(), and <a href="qsettings.html#applicationName">applicationName</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/group" />
<h3 class="fn"><a name="group" />QString QSettings.group (<i>self</i>)</h3><p>Returns the current group.</p>
<p>See also <a href="qsettings.html#beginGroup">beginGroup</a>() and <a href="qsettings.html#endGroup">endGroup</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/iniCodec" />
<h3 class="fn"><a name="iniCodec" /><a href="qtextcodec.html">QTextCodec</a> QSettings.iniCodec (<i>self</i>)</h3><p>Returns the codec that is used for accessing INI files. By default, no codec is used, so a null pointer is returned.</p>
<p>This function was introduced in Qt 4.5.</p>
<p>See also <a href="qsettings.html#setIniCodec">setIniCodec</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/isWritable" />
<h3 class="fn"><a name="isWritable" />bool QSettings.isWritable (<i>self</i>)</h3><p>Returns true if settings can be written using this <a href="qsettings.html">QSettings</a> object; returns false otherwise.</p>
<p>One reason why isWritable() might return false is if <a href="qsettings.html">QSettings</a> operates on a read-only file.</p>
<p><b>Warning:</b> This function is not perfectly reliable, because the file permissions can change at any time.</p>
<p>See also <a href="qsettings.html#fileName">fileName</a>(), <a href="qsettings.html#status">status</a>(), and <a href="qsettings.html#sync">sync</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/organizationName" />
<h3 class="fn"><a name="organizationName" />QString QSettings.organizationName (<i>self</i>)</h3><p>Returns the organization name used for storing the settings.</p>
<p>This function was introduced in Qt 4.4.</p>
<p>See also <a href="qcoreapplication.html#organizationName-prop">QCoreApplication.organizationName</a>(), <a href="qsettings.html#format">format</a>(), <a href="qsettings.html#scope">scope</a>(), and <a href="qsettings.html#applicationName">applicationName</a>().</p>
<a name="//apple_ref/cpp/clm/QSettings/registerFormat" />
<h3 class="fn"><a name="remove" />QSettings.remove (<i>self</i>, QString)</h3><p>Removes the setting <i>key</i> and any sub-settings of <i>key</i>.</p>
<p>Example:</p>
<pre> QSettings settings;
 settings.setValue("ape");
 settings.setValue("monkey", 1);
 settings.setValue("monkey/sea", 2);
 settings.setValue("monkey/doe", 4);

 settings.remove("monkey");
 QStringList keys = settings.allKeys();
<span class="comment"> // keys: ["ape"]</span></pre>
<p>Be aware that if one of the fallback locations contains a setting with the same key, that setting will be visible after calling remove().</p>
<p>If <i>key</i> is an empty string, all keys in the current <a href="qsettings.html#group">group</a>() are removed. For example:</p>
<pre> QSettings settings;
 settings.setValue("ape");
 settings.setValue("monkey", 1);
 settings.setValue("monkey/sea", 2);
 settings.setValue("monkey/doe", 4);

 settings.beginGroup("monkey");
 settings.remove("");
 settings.endGroup();

 QStringList keys = settings.allKeys();
<span class="comment"> // keys: ["ape"]</span></pre>
<p>Note that the Windows registry and INI files use case-insensitive keys, whereas the Carbon Preferences API on Mac OS X uses case-sensitive keys. To avoid portability problems, see the <a href="qsettings.html#section-and-key-syntax">Section and Key Syntax</a> rules.</p>
<p>See also <a href="qsettings.html#setValue">setValue</a>(), <a href="qsettings.html#value">value</a>(), and <a href="qsettings.html#contains">contains</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/scope" />
<h3 class="fn"><a name="scope" /><a href="qsettings.html#Scope-enum">Scope</a> QSettings.scope (<i>self</i>)</h3><p>Returns the scope used for storing the settings.</p>
<p>This function was introduced in Qt 4.4.</p>
<p>See also <a href="qsettings.html#format">format</a>(), <a href="qsettings.html#organizationName">organizationName</a>(), and <a href="qsettings.html#applicationName">applicationName</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/setArrayIndex" />
<h3 class="fn"><a name="setArrayIndex" />QSettings.setArrayIndex (<i>self</i>, int)</h3><p>Sets the current array index to <i>i</i>. Calls to functions such as <a href="qsettings.html#setValue">setValue</a>(), <a href="qsettings.html#value">value</a>(), <a href="qsettings.html#remove">remove</a>(), and <a href="qsettings.html#contains">contains</a>() will operate on the array entry at that index.</p>
<p>You must call <a href="qsettings.html#beginReadArray">beginReadArray</a>() or <a href="qsettings.html#beginWriteArray">beginWriteArray</a>() before you can call this function.</p>
<a name="//apple_ref/cpp/clm/QSettings/setDefaultFormat" />
<h3 class="fn"><a name="setDefaultFormat" />QSettings.setDefaultFormat (<a href="qsettings.html#Format-enum">Format</a>)</h3><p>Sets the default file format to the given <i>format</i>, which is used for storing settings for the <a href="qsettings.html">QSettings</a>(<a href="qobject.html">QObject</a> *) constructor.</p>
<p>If no default format is set, <a href="qsettings.html#Format-enum">QSettings.NativeFormat</a> is used. See the documentation for the <a href="qsettings.html">QSettings</a> constructor you are using to see if that constructor will ignore this function.</p>
<p>This function was introduced in Qt 4.4.</p>
<p>See also <a href="qsettings.html#defaultFormat">defaultFormat</a>() and <a href="qsettings.html#format">format</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/setFallbacksEnabled" />
<h3 class="fn"><a name="setFallbacksEnabled" />QSettings.setFallbacksEnabled (<i>self</i>, bool)</h3><p>Sets whether fallbacks are enabled to <i>b</i>.</p>
<p>By default, fallbacks are enabled.</p>
<p>See also <a href="qsettings.html#fallbacksEnabled">fallbacksEnabled</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/setIniCodec" />
<h3 class="fn"><a name="setIniCodec" />QSettings.setIniCodec (<i>self</i>, <a href="qtextcodec.html">QTextCodec</a>)</h3><p>Sets the codec for accessing INI files (including <tt>.conf</tt> files on Unix) to <i>codec</i>. The codec is used for decoding any data that is read from the INI file, and for encoding any data that is written to the file. By default, no codec is used, and non-ASCII characters are encoded using standard INI escape sequences.</p>
<p><b>Warning:</b> The codec must be set immediately after creating the <a href="qsettings.html">QSettings</a> object, before accessing any data.</p>
<p>This function was introduced in Qt 4.5.</p>
<p>See also <a href="qsettings.html#iniCodec">iniCodec</a>().</p>
<h3 class="fn"><a name="setIniCodec-2" />QSettings.setIniCodec (<i>self</i>, str)</h3><p>This is an overloaded function.</p>
<p>Sets the codec for accessing INI files (including <tt>.conf</tt> files on Unix) to the <a href="qtextcodec.html">QTextCodec</a> for the encoding specified by <i>codecName</i>. Common values for <tt>codecName</tt> include "ISO 8859-1", "UTF-8", and "UTF-16". If the encoding isn't recognized, nothing happens.</p>
<p>This function was introduced in Qt 4.5.</p>
<p>See also <a href="qtextcodec.html#codecForName">QTextCodec.codecForName</a>().</p>
<a name="//apple_ref/cpp/clm/QSettings/setPath" />
<h3 class="fn"><a name="setPath" />QSettings.setPath (<a href="qsettings.html#Format-enum">Format</a>, <a href="qsettings.html#Scope-enum">Scope</a>, QString)</h3><p>Sets the path used for storing settings for the given <i>format</i> and <i>scope</i>, to <i>path</i>. The <i>format</i> can be a custom format.</p>
<p>The table below summarizes the default values:</p>
<p><table align="center" border="0" cellpadding="2" cellspacing="1" class="generic">
<thead><tr class="qt-style" valign="top"><th>Platform</th><th>Format</th><th>Scope</th><th>Path</th></tr></thead>
<tr class="odd" valign="top"><td rowspan="2">Windows</td><td rowspan="2"><a href="qsettings.html#Format-enum">IniFormat</a></td><td><a href="qsettings.html#Scope-enum">UserScope</a></td><td><tt>%APPDATA%</tt></td></tr>
<tr class="even" valign="top"><td><a href="qsettings.html#Scope-enum">SystemScope</a></td><td><tt>%COMMON_APPDATA%</tt></td></tr>
<tr class="odd" valign="top"><td rowspan="2">Unix</td><td rowspan="2"><a href="qsettings.html#Format-enum">NativeFormat</a>, <a href="qsettings.html#Format-enum">IniFormat</a></td><td><a href="qsettings.html#Scope-enum">UserScope</a></td><td><tt>$HOME/.config</tt></td></tr>
<tr class="even" valign="top"><td><a href="qsettings.html#Scope-enum">SystemScope</a></td><td><tt>/etc/xdg</tt></td></tr>
<tr class="odd" valign="top"><td rowspan="2">Qt for Embedded Linux</td><td rowspan="2"><a href="qsettings.html#Format-enum">NativeFormat</a>, <a href="qsettings.html#Format-enum">IniFormat</a></td><td><a href="qsettings.html#Scope-enum">UserScope</a></td><td><tt>$HOME/Settings</tt></td></tr>
<tr class="even" valign="top"><td><a href="qsettings.html#Scope-enum">SystemScope</a></td><td><tt>/etc/xdg</tt></td></tr>
<tr class="odd" valign="top"><td rowspan="2">Mac OS X</td><td rowspan="2"><a href="qsettings.html#Format-enum">IniFormat</a></td><td><a href="qsettings.html#Scope-enum">UserScope</a></td><td><tt>$HOME/.config</tt></td></tr>
<tr class="even" valign="top"><td><a href="qsettings.html#Scope-enum">SystemScope</a></td><td><tt>/etc/xdg</tt></td></tr>
</table></p>
<p>The default <a href="qsettings.html#Scope-enum">UserScope</a> paths on Unix and Mac OS X (<tt>$HOME/.config</tt> or $HOME/Settings) can be overridden by the user by setting the <tt>XDG_CONFIG_HOME</tt> environment variable. The default <a href="qsettings.html#Scope-enum">SystemScope</a> paths on Unix and Mac OS X (<tt>/etc/xdg</tt>) can be overridden when building the Qt library using the <tt>configure</tt> script's <tt>--sysconfdir</tt> flag (see <a href="qlibraryinfo.html">QLibraryInfo</a> for details).</p>
<p>Setting the <a href="qsettings.html#Format-enum">NativeFormat</a> paths on Windows and Mac OS X has no effect.</p>
<p><b>Warning:</b> This function doesn't affect existing <a href="qsettings.html">QSettings</a> objects.</p>
<p>This function was introduced in Qt 4.1.</p>
<p>See also <a href="qsettings.html#registerFormat">registerFormat</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/setValue" />
<h3 class="fn"><a name="setSystemIniPath" />QSettings.setSystemIniPath (QString)</h3><h3 class="fn"><a name="setUserIniPath" />QSettings.setUserIniPath (QString)</h3><h3 class="fn"><a name="setValue" />QSettings.setValue (<i>self</i>, QString, QVariant)</h3><p>Sets the value of setting <i>key</i> to <i>value</i>. If the <i>key</i> already exists, the previous value is overwritten.</p>
<p>Note that the Windows registry and INI files use case-insensitive keys, whereas the Carbon Preferences API on Mac OS X uses case-sensitive keys. To avoid portability problems, see the <a href="qsettings.html#section-and-key-syntax">Section and Key Syntax</a> rules.</p>
<p>Example:</p>
<pre> QSettings settings;
 settings.setValue("interval", 30);
 settings.value("interval").toInt();     <span class="comment">// returns 30</span>

 settings.setValue("interval", 6.55);
 settings.value("interval").toDouble();  <span class="comment">// returns 6.55</span></pre>
<p>See also <a href="qsettings.html#value">value</a>(), <a href="qsettings.html#remove">remove</a>(), and <a href="qsettings.html#contains">contains</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/status" />
<h3 class="fn"><a name="status" /><a href="qsettings.html#Status-enum">Status</a> QSettings.status (<i>self</i>)</h3><p>Returns a status code indicating the first error that was met by <a href="qsettings.html">QSettings</a>, or <a href="qsettings.html#Status-enum">QSettings.NoError</a> if no error occurred.</p>
<p>Be aware that <a href="qsettings.html">QSettings</a> delays performing some operations. For this reason, you might want to call <a href="qsettings.html#sync">sync</a>() to ensure that the data stored in <a href="qsettings.html">QSettings</a> is written to disk before calling status().</p>
<p>See also <a href="qsettings.html#sync">sync</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/sync" />
<h3 class="fn"><a name="sync" />QSettings.sync (<i>self</i>)</h3><p>Writes any unsaved changes to permanent storage, and reloads any settings that have been changed in the meantime by another application.</p>
<p>This function is called automatically from <a href="qsettings.html">QSettings</a>'s destructor and by the event loop at regular intervals, so you normally don't need to call it yourself.</p>
<p>See also <a href="qsettings.html#status">status</a>().</p>
<a name="//apple_ref/cpp/instm/QSettings/value" />
<h3 class="fn"><a name="value" />QVariant QSettings.value (<i>self</i>, QString, QVariant&#160;<i>defaultValue</i>&#160;=&#160;QVariant())</h3><p>Returns the value for setting <i>key</i>. If the setting doesn't exist, returns <i>defaultValue</i>.</p>
<p>If no default value is specified, a default <a href="qvariant.html">QVariant</a> is returned.</p>
<p>Note that the Windows registry and INI files use case-insensitive keys, whereas the Carbon Preferences API on Mac OS X uses case-sensitive keys. To avoid portability problems, see the <a href="qsettings.html#section-and-key-syntax">Section and Key Syntax</a> rules.</p>
<p>Example:</p>
<pre> QSettings settings;
 settings.setValue("animal/snake", 58);
 settings.value("animal/snake", 1024).toInt();   <span class="comment">// returns 58</span>
 settings.value("animal/zebra", 1024).toInt();   <span class="comment">// returns 1024</span>
 settings.value("animal/zebra").toInt();         <span class="comment">// returns 0</span></pre>
<p>See also <a href="qsettings.html#setValue">setValue</a>(), <a href="qsettings.html#contains">contains</a>(), and <a href="qsettings.html#remove">remove</a>().</p>
<p /><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.7.3 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2010</td><td align="right" width="25%">Qt&#160;4.6.2</td></tr></table></div></address></body></html>