Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > 28b9e36e96ce34b2567ae5b47a27b2c5 > files > 992

python-qt4-doc-4.10.3-3.mga4.noarch.rpm

<?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="index.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&#160;<i>organization</i>, 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&#160;<i>scope</i>, QString&#160;<i>organization</i>, 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&#160;<i>format</i>, Scope&#160;<i>scope</i>, QString&#160;<i>organization</i>, 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&#160;<i>fileName</i>, Format&#160;<i>format</i>, 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&#160;<i>prefix</i>)</li><li><div class="fn" />int <b><a href="qsettings.html#beginReadArray">beginReadArray</a></b> (<i>self</i>, QString&#160;<i>prefix</i>)</li><li><div class="fn" /><b><a href="qsettings.html#beginWriteArray">beginWriteArray</a></b> (<i>self</i>, QString&#160;<i>prefix</i>, 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&#160;<i>key</i>)</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&#160;<i>event</i>)</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&#160;<i>key</i>)</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&#160;<i>i</i>)</li><li><div class="fn" /><b><a href="qsettings.html#setFallbacksEnabled">setFallbacksEnabled</a></b> (<i>self</i>, bool&#160;<i>b</i>)</li><li><div class="fn" /><b><a href="qsettings.html#setIniCodec">setIniCodec</a></b> (<i>self</i>, QTextCodec&#160;<i>codec</i>)</li><li><div class="fn" /><b><a href="qsettings.html#setIniCodec-2">setIniCodec</a></b> (<i>self</i>, str&#160;<i>codecName</i>)</li><li><div class="fn" /><b><a href="qsettings.html#setValue">setValue</a></b> (<i>self</i>, QString&#160;<i>key</i>, QVariant&#160;<i>value</i>)</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" />object <b><a href="qsettings.html#value">value</a></b> (<i>self</i>, QString&#160;<i>key</i>, QVariant&#160;<i>defaultValue</i>&#160;=&#160;QVariant(), object&#160;<i>type</i>&#160;=&#160;None)</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&#160;<i>format</i>)</li><li><div class="fn" /><b><a href="qsettings.html#setPath">setPath</a></b> (Format&#160;<i>format</i>, Scope&#160;<i>scope</i>, QString&#160;<i>path</i>)</li><li><div class="fn" /><b><a href="qsettings.html#setSystemIniPath">setSystemIniPath</a></b> (QString&#160;<i>dir</i>)</li><li><div class="fn" /><b><a href="qsettings.html#setUserIniPath">setUserIniPath</a></b> (QString&#160;<i>dir</i>)</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>
<a id="basic-usage" 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 class="cpp">
     <span class="type">QSettings</span> settings(<span class="string">"MySoft"</span><span class="operator">,</span> <span class="string">"Star Runner"</span>);
</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 class="cpp">
     <span class="type"><a href="qcoreapplication.html">QCoreApplication</a></span><span class="operator">.</span>setOrganizationName(<span class="string">"MySoft"</span>);
     <span class="type"><a href="qcoreapplication.html">QCoreApplication</a></span><span class="operator">.</span>setOrganizationDomain(<span class="string">"mysoft.com"</span>);
     <span class="type"><a href="qcoreapplication.html">QCoreApplication</a></span><span class="operator">.</span>setApplicationName(<span class="string">"Star Runner"</span>);
     ...
     <span class="type">QSettings</span> 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 class="cpp">
     settings<span class="operator">.</span>setValue(<span class="string">"editor/wrapMargin"</span><span class="operator">,</span> <span class="number">68</span>);
</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 class="cpp">
     <span class="type">int</span> margin <span class="operator">=</span> settings<span class="operator">.</span>value(<span class="string">"editor/wrapMargin"</span>)<span class="operator">.</span>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 class="cpp">
     <span class="type">int</span> margin <span class="operator">=</span> settings<span class="operator">.</span>value(<span class="string">"editor/wrapMargin"</span><span class="operator">,</span> <span class="number">80</span>)<span class="operator">.</span>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 id="qvariant-and-gui-types" 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 class="compat" href="qvariant-qt3.html#qVariantValue">qVariantValue</a>() template function. For example:</p>
<pre class="cpp">
 <span class="type">QSettings</span> settings(<span class="string">"MySoft"</span><span class="operator">,</span> <span class="string">"Star Runner"</span>);
 <span class="type"><a href="qcolor.html">QColor</a></span> color <span class="operator">=</span> settings<span class="operator">.</span><a href="qsettings.html#value">value</a>(<span class="string">"DataPump/bgcolor"</span>)<span class="operator">.</span>value<span class="operator">&lt;</span><span class="type"><a href="qcolor.html">QColor</a></span><span class="operator">&gt;</span>();
</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 class="cpp">
 <span class="type">QSettings</span> settings(<span class="string">"MySoft"</span><span class="operator">,</span> <span class="string">"Star Runner"</span>);
 <span class="type"><a href="qcolor.html">QColor</a></span> color <span class="operator">=</span> palette()<span class="operator">.</span>background()<span class="operator">.</span>color();
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"DataPump/bgcolor"</span><span class="operator">,</span> 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 id="section-and-key-syntax" 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 class="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 class="cpp">
     settings<span class="operator">.</span>setValue(<span class="string">"mainwindow/size"</span><span class="operator">,</span> win<span class="operator">-</span><span class="operator">&gt;</span>size());
     settings<span class="operator">.</span>setValue(<span class="string">"mainwindow/fullScreen"</span><span class="operator">,</span> win<span class="operator">-</span><span class="operator">&gt;</span>isFullScreen());
     settings<span class="operator">.</span>setValue(<span class="string">"outputpanel/visible"</span><span class="operator">,</span> panel<span class="operator">-</span><span class="operator">&gt;</span>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 class="cpp">
     settings<span class="operator">.</span>beginGroup(<span class="string">"mainwindow"</span>);
     settings<span class="operator">.</span>setValue(<span class="string">"size"</span><span class="operator">,</span> win<span class="operator">-</span><span class="operator">&gt;</span>size());
     settings<span class="operator">.</span>setValue(<span class="string">"fullScreen"</span><span class="operator">,</span> win<span class="operator">-</span><span class="operator">&gt;</span>isFullScreen());
     settings<span class="operator">.</span>endGroup();

     settings<span class="operator">.</span>beginGroup(<span class="string">"outputpanel"</span>);
     settings<span class="operator">.</span>setValue(<span class="string">"visible"</span><span class="operator">,</span> panel<span class="operator">-</span><span class="operator">&gt;</span>isVisible());
     settings<span class="operator">.</span>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 id="fallback-mechanism" 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 class="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 class="cpp">
     <span class="type">QSettings</span> obj1(<span class="string">"MySoft"</span><span class="operator">,</span> <span class="string">"Star Runner"</span>);
     <span class="type">QSettings</span> obj2(<span class="string">"MySoft"</span>);
     <span class="type">QSettings</span> obj3(<span class="type">QSettings</span><span class="operator">.</span>SystemScope<span class="operator">,</span> <span class="string">"MySoft"</span><span class="operator">,</span> <span class="string">"Star Runner"</span>);
     <span class="type">QSettings</span> obj4(<span class="type">QSettings</span><span class="operator">.</span>SystemScope<span class="operator">,</span> <span class="string">"MySoft"</span>);
</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>
<table class="generic">
<thead>
<tr class="qt-style">
<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>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 class="cpp">
     <span class="type">QSettings</span> settings(<span class="type">QSettings</span><span class="operator">.</span>IniFormat<span class="operator">,</span> <span class="type">QSettings</span><span class="operator">.</span>UserScope<span class="operator">,</span>
                        <span class="string">"MySoft"</span><span class="operator">,</span> <span class="string">"Star Runner"</span>);
</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 id="restoring-the-state-of-a-gui-application" 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 class="cpp">
 <span class="type">void</span> MainWindow<span class="operator">.</span>writeSettings()
 {
     <span class="type">QSettings</span> settings(<span class="string">"Moose Soft"</span><span class="operator">,</span> <span class="string">"Clipper"</span>);

     settings<span class="operator">.</span>beginGroup(<span class="string">"MainWindow"</span>);
     settings<span class="operator">.</span>setValue(<span class="string">"size"</span><span class="operator">,</span> size());
     settings<span class="operator">.</span>setValue(<span class="string">"pos"</span><span class="operator">,</span> pos());
     settings<span class="operator">.</span>endGroup();
 }

 <span class="type">void</span> MainWindow<span class="operator">.</span>readSettings()
 {
     <span class="type">QSettings</span> settings(<span class="string">"Moose Soft"</span><span class="operator">,</span> <span class="string">"Clipper"</span>);

     settings<span class="operator">.</span>beginGroup(<span class="string">"MainWindow"</span>);
     resize(settings<span class="operator">.</span>value(<span class="string">"size"</span><span class="operator">,</span> <span class="type"><a href="qsize.html">QSize</a></span>(<span class="number">400</span><span class="operator">,</span> <span class="number">400</span>))<span class="operator">.</span>toSize());
     move(settings<span class="operator">.</span>value(<span class="string">"pos"</span><span class="operator">,</span> <span class="type"><a href="qpoint.html">QPoint</a></span>(<span class="number">200</span><span class="operator">,</span> <span class="number">200</span>))<span class="operator">.</span>toPoint());
     settings<span class="operator">.</span>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 class="cpp">
 MainWindow<span class="operator">.</span>MainWindow()
 {
     ...
     readSettings();
 }

 <span class="type">void</span> MainWindow<span class="operator">.</span>closeEvent(<span class="type"><a href="qcloseevent.html">QCloseEvent</a></span> <span class="operator">*</span>event)
 {
     <span class="keyword">if</span> (userReallyWantsToQuit()) {
         writeSettings();
         event<span class="operator">-</span><span class="operator">&gt;</span>accept();
     } <span class="keyword">else</span> {
         event<span class="operator">-</span><span class="operator">&gt;</span>ignore();
     }
 }
</pre>
<p>See the <a href="mainwindows-application.html">Application</a>
example for a self-contained example that uses QSettings.</p>
<a id="accessing-settings-from-multiple-threads-or-processes-simultaneously" 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. Note that <a href="qsettings.html#sync">sync</a>() imports changes made by other
processes (in addition to writing the changes from this
QSettings).</p>
<a id="platform-specific-notes" name="platform-specific-notes" />
<h3>Platform-Specific Notes</h3>
<a id="locations-where-application-settings-are-stored" 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 class="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 class="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 class="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 class="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 class="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>On Symbian, the following files are used for both <a href="qsettings.html#Format-enum">IniFormat</a> and <a href="qsettings.html#Format-enum">NativeFormat</a> (in this example, we
assume that the application is installed on the <tt>e-drive</tt>
and its Secure ID is <tt>0xECB00931</tt>):</p>
<ol class="1">
<li><tt>c:\data\.config\MySoft\Star Runner.conf</tt></li>
<li><tt>c:\data\.config\MySoft.conf</tt></li>
<li><tt>e:\private\ecb00931\MySoft\Star Runner.conf</tt></li>
<li><tt>e:\private\ecb00931\MySoft.conf</tt></li>
</ol>
<p>The <a href="qsettings.html#Scope-enum">SystemScope</a> settings
location is determined from the installation drive and Secure ID
(UID3) of the application. If the application is built-in on the
ROM, the drive used for <a href="qsettings.html#Scope-enum">SystemScope</a> is <tt>c:</tt>.</p>
<p><b>Note:</b> Symbian <a href="qsettings.html#Scope-enum">SystemScope</a> settings are by default
private to the application and not shared between applications,
unlike other environments.</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 id="accessing-ini-and-plist-files-directly" 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 class="cpp">
 <span class="type">QSettings</span> settings(<span class="string">"/home/petra/misc/myapp.ini"</span><span class="operator">,</span>
                    <span class="type">QSettings</span><span class="operator">.</span>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 class="cpp">
 <span class="type">QSettings</span> settings(<span class="string">"/Users/petra/misc/myapp.plist"</span><span class="operator">,</span>
                    <span class="type">QSettings</span><span class="operator">.</span>NativeFormat);
</pre>
<a id="accessing-the-windows-registry-directly" 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 class="cpp">
 <span class="type">QSettings</span> settings(<span class="string">"HKEY_CURRENT_USER\\Software\\Microsoft\\Office"</span><span class="operator">,</span>
                    <span class="type">QSettings</span><span class="operator">.</span>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 class="cpp">
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"11.0/Outlook/Security/DontTrustInstalledFiles"</span><span class="operator">,</span> <span class="number">0</span>);
</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 id="accessing-common-registry-settings-on-windows" 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 class="cpp">
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"HKEY_CURRENT_USER\\MySoft\\Star Runner\\Galaxy"</span><span class="operator">,</span> <span class="string">"Milkyway"</span>);
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"HKEY_CURRENT_USER\\MySoft\\Star Runner\\Galaxy\\Sun"</span><span class="operator">,</span> <span class="string">"OurStar"</span>);
 settings<span class="operator">.</span><a href="qsettings.html#value">value</a>(<span class="string">"HKEY_CURRENT_USER\\MySoft\\Star Runner\\Galaxy\\Default"</span>); <span class="comment">// returns "Milkyway"</span>
</pre>
<p>On other platforms than Windows, "Default" and "." would be
treated as regular subkeys.</p>
<a id="securing-application-settings-in-symbian" name="securing-application-settings-in-symbian" />
<h4>Securing application settings in Symbian</h4>
<p><a href="qsettings.html#Scope-enum">UserScope</a> settings in
Symbian are writable by any application by default. To protect the
application settings from access and tampering by other
applications, the settings need to be placed in the private secure
area of the application. This can be done by specifying the
settings storage path directly to the private area. The following
snippet changes the <a href="qsettings.html#Scope-enum">UserScope</a> to
<tt>c:/private/ecb00931/MySoft.conf</tt> (provided the application
is installed on the <tt>c-drive</tt> and its Secure ID is
<tt>0xECB00931</tt>:</p>
<pre class="cpp">
 <span class="type">QSettings</span> settings(<span class="type"><a href="qapplication.html">QApplication</a></span><span class="operator">.</span>applicationDirPath() <span class="operator">+</span> <span class="string">"/MySoft.conf"</span>);
</pre>
<p>Framework libraries (like Qt itself) may store configuration and
cache settings using <a href="qsettings.html#Scope-enum">UserScope</a>, which is accessible and
writable by other applications. If the application is very security
sensitive or uses high platform security capabilities, it may be
prudent to also force framework settings to be stored in the
private directory of the application. This can be done by changing
the default path of <a href="qsettings.html#Scope-enum">UserScope</a> before <a href="qapplication.html">QApplication</a> is created:</p>
<pre class="cpp">
 <span class="preprocessor">#include &lt;QSettings&gt;</span>
 <span class="preprocessor">#include &lt;QDesktopServices&gt;</span>
 <span class="type">int</span> main(<span class="type">int</span> argc<span class="operator">,</span> <span class="type">char</span> <span class="operator">*</span>argv<span class="operator">[</span><span class="operator">]</span>)
 {
 <span class="preprocessor">#ifdef Q_OS_SYMBIAN</span>
     <span class="comment">// Use QDesktopServices:storageLocation as QApplication is not yet created</span>
     <span class="type">QSettings</span><span class="operator">.</span>setPath(
         <span class="type">QSettings</span><span class="operator">.</span>NativeFormat<span class="operator">,</span> <span class="type">QSettings</span><span class="operator">.</span>UserScope<span class="operator">,</span>
         <span class="type"><a href="qdesktopservices.html">QDesktopServices</a></span><span class="operator">.</span>storageLocation(<span class="type"><a href="qdesktopservices.html">QDesktopServices</a></span><span class="operator">.</span>DataLocation) <span class="operator">+</span> <span class="string">"/settings"</span>);
 <span class="preprocessor">#endif</span>
     <span class="type"><a href="qapplication.html">QApplication</a></span> app(argc<span class="operator">,</span> argv);

     <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
 }
</pre>
<p>Note that this may affect framework libraries' functionality if
they expect the settings to be shared between applications.</p>
<a id="changing-the-location-of-global-qt-settings-on-mac-os-x" name="changing-the-location-of-global-qt-settings-on-mac-os-x" />
<h4>Changing the location of global Qt settings on Mac OS X</h4>
<p>On Mac OS X, the global Qt settings (stored in
<tt>com.trolltech.plist</tt>) are stored in the application
settings file in two situations:</p>
<ol class="1">
<li>If the application runs in a Mac OS X sandbox (on Mac OS X 10.7
or later) or</li>
<li>If the <tt>Info.plist</tt> file of the application contains the
key <tt>"ForAppStore"</tt> with the value <tt>"yes"</tt></li>
</ol>
<p>In these situations, the application settings file is named
using the bundle identifier of the application, which must
consequently be set in the application's <tt>Info.plist</tt>
file.</p>
<p>This feature is provided to ease the acceptance of Qt
applications into the Mac App Store, as the default behaviour of
storing global Qt settings in the <tt>com.trolltech.plist</tt> file
does not conform with Mac App Store file system usage requirements.
For more information about submitting Qt applications to the Mac
App Store, see <a href="mac-differences.html#preparing-a-qt-application-for-mac-app-store-submission">
Preparing a Qt application for Mac App Store submission</a>.</p>
<a id="platform-limitations" 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 class="cpp">
 <span class="preprocessor">#ifdef Q_WS_MAC</span>
     <span class="type">QSettings</span> settings(<span class="string">"grenoullelogique.fr"</span><span class="operator">,</span> <span class="string">"Squash"</span>);
 <span class="preprocessor">#else</span>
     <span class="type">QSettings</span> settings(<span class="string">"Grenoulle Logique"</span><span class="operator">,</span> <span class="string">"Squash"</span>);
 <span class="preprocessor">#endif</span>
</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>
<li>On the BlackBerry platform, applications run in a sandbox. They
are not allowed to read or write outside of this sandbox. This
involves the following limitations:
<ul>
<li>As there is only a single scope the scope is simply
ignored.</li>
<li>The <a href="#fallback-mechanism">Fallback Mechanism</a> is not
applied, i.e. only a single location is considered.</li>
<li>It is advised against setting and using custom file paths.</li>
</ul>
</li>
</ul>
<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>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QSettings.NativeFormat</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">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 class="topAlign"><tt>QSettings.IniFormat</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">Store the settings in INI files.</td>
</tr>
<tr>
<td class="topAlign"><tt>QSettings.InvalidFormat</tt></td>
<td class="topAlign"><tt>16</tt></td>
<td class="topAlign">Special value returned by <a href="qsettings.html#registerFormat">registerFormat</a>().</td>
</tr>
</table>
<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 class="cpp">
 pos <span class="operator">=</span> @Point(<span class="number">100</span> <span class="number">100</span>)
</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 class="cpp">
 windir <span class="operator">=</span> 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><b>See also</b> <a href="qsettings.html#registerFormat">registerFormat</a>() and <a href="qsettings.html#setPath">setPath</a>().</p>


<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>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QSettings.UserScope</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">Store settings in a location specific to the
current user (e.g., in the user's home directory).</td>
</tr>
<tr>
<td class="topAlign"><tt>QSettings.SystemScope</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">Store settings in a global location, so that
all users on the same machine access the same set of settings.</td>
</tr>
</table>
<p><b>See also</b> <a href="qsettings.html#setPath">setPath</a>().</p>


<h3 class="fn"><a name="Status-enum" />QSettings.Status</h3><p>The following status values are possible:</p>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QSettings.NoError</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">No error occurred.</td>
</tr>
<tr>
<td class="topAlign"><tt>QSettings.AccessError</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">An access error occurred (e.g. trying to write
to a read-only file).</td>
</tr>
<tr>
<td class="topAlign"><tt>QSettings.FormatError</tt></td>
<td class="topAlign"><tt>2</tt></td>
<td class="topAlign">A format error occurred (e.g. loading a
malformed INI file).</td>
</tr>
</table>
<p><b>See also</b> <a href="qsettings.html#status">status</a>().</p>


<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QSettings" />QSettings.__init__ (<i>self</i>, QString&#160;<i>organization</i>, 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 class="cpp">
 <span class="type"><a href="qsettings.html">QSettings</a></span> settings(<span class="string">"Moose Tech"</span><span class="operator">,</span> <span class="string">"Facturo-Pro"</span>);
</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><b>See also</b> <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>&#160;<i>scope</i>, QString&#160;<i>organization</i>, 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><b>See also</b> <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>&#160;<i>format</i>, <a href="qsettings.html#Scope-enum">Scope</a>&#160;<i>scope</i>, QString&#160;<i>organization</i>, 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&#160;<i>fileName</i>, <a href="qsettings.html#Format-enum">Format</a>&#160;<i>format</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 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><b>See also</b> <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 class="cpp">
 <span class="type"><a href="qsettings.html">QSettings</a></span> settings(<span class="string">"Moose Soft"</span><span class="operator">,</span> <span class="string">"Facturo-Pro"</span>);
</pre>
<p>is equivalent to</p>
<pre class="cpp">
 <span class="type"><a href="qcoreapplication.html">QCoreApplication</a></span><span class="operator">.</span>setOrganizationName(<span class="string">"Moose Soft"</span>);
 <span class="type"><a href="qcoreapplication.html">QCoreApplication</a></span><span class="operator">.</span>setApplicationName(<span class="string">"Facturo-Pro"</span>);
 <span class="type"><a href="qsettings.html">QSettings</a></span> 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><b>See also</b> <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>


<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 class="cpp">
 <span class="type"><a href="qsettings.html">QSettings</a></span> settings;
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"fridge/color"</span><span class="operator">,</span> <span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>white);
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"fridge/size"</span><span class="operator">,</span> <span class="type"><a href="qsize.html">QSize</a></span>(<span class="number">32</span><span class="operator">,</span> <span class="number">96</span>));
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"sofa"</span><span class="operator">,</span> <span class="keyword">true</span>);
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"tv"</span><span class="operator">,</span> <span class="keyword">false</span>);

 <span class="type"><a href="qstringlist.html">QStringList</a></span> keys <span class="operator">=</span> settings<span class="operator">.</span>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 class="cpp">
 settings<span class="operator">.</span><a href="qsettings.html#beginGroup">beginGroup</a>(<span class="string">"fridge"</span>);
 keys <span class="operator">=</span> settings<span class="operator">.</span>allKeys();
 <span class="comment">// keys: ["color", "size"]</span>
</pre>
<p><b>See also</b> <a href="qsettings.html#childGroups">childGroups</a>() and <a href="qsettings.html#childKeys">childKeys</a>().</p>


<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><b>See also</b> <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>


<h3 class="fn"><a name="beginGroup" />QSettings.beginGroup (<i>self</i>, QString&#160;<i>prefix</i>)</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 class="cpp">
 settings<span class="operator">.</span>beginGroup(<span class="string">"mainwindow"</span>);
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"size"</span><span class="operator">,</span> win<span class="operator">-</span><span class="operator">&gt;</span>size());
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"fullScreen"</span><span class="operator">,</span> win<span class="operator">-</span><span class="operator">&gt;</span>isFullScreen());
 settings<span class="operator">.</span><a href="qsettings.html#endGroup">endGroup</a>();

 settings<span class="operator">.</span>beginGroup(<span class="string">"outputpanel"</span>);
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"visible"</span><span class="operator">,</span> panel<span class="operator">-</span><span class="operator">&gt;</span>isVisible());
 settings<span class="operator">.</span><a href="qsettings.html#endGroup">endGroup</a>();
</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><b>See also</b> <a href="qsettings.html#endGroup">endGroup</a>()
and <a href="qsettings.html#group">group</a>().</p>


<h3 class="fn"><a name="beginReadArray" />int QSettings.beginReadArray (<i>self</i>, QString&#160;<i>prefix</i>)</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 class="cpp">
 <span class="keyword">struct</span> Login {
     <span class="type"><a href="qstring.html">QString</a></span> userName;
     <span class="type"><a href="qstring.html">QString</a></span> password;
 };
 <span class="type"><a href="qlist.html">QList</a></span><span class="operator">&lt;</span>Login<span class="operator">&gt;</span> logins;
 <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>

 <span class="type"><a href="qsettings.html">QSettings</a></span> settings;
 <span class="type">int</span> size <span class="operator">=</span> settings<span class="operator">.</span>beginReadArray(<span class="string">"logins"</span>);
 <span class="keyword">for</span> (<span class="type">int</span> i <span class="operator">=</span> <span class="number">0</span>; i <span class="operator">&lt;</span> size; <span class="operator">+</span><span class="operator">+</span>i) {
     settings<span class="operator">.</span>setArrayIndex(i);
     Login login;
     login<span class="operator">.</span>userName <span class="operator">=</span> settings<span class="operator">.</span>value(<span class="string">"userName"</span>)<span class="operator">.</span>toString();
     login<span class="operator">.</span>password <span class="operator">=</span> settings<span class="operator">.</span>value(<span class="string">"password"</span>)<span class="operator">.</span>toString();
     logins<span class="operator">.</span>append(login);
 }
 settings<span class="operator">.</span><a href="qsettings.html#endArray">endArray</a>();
</pre>
<p>Use <a href="qsettings.html#beginWriteArray">beginWriteArray</a>() to write the
array in the first place.</p>
<p><b>See also</b> <a href="qsettings.html#beginWriteArray">beginWriteArray</a>(), <a href="qsettings.html#endArray">endArray</a>(), and <a href="qsettings.html#setArrayIndex">setArrayIndex</a>().</p>


<h3 class="fn"><a name="beginWriteArray" />QSettings.beginWriteArray (<i>self</i>, QString&#160;<i>prefix</i>, 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 class="cpp">
 <span class="keyword">struct</span> Login {
     <span class="type"><a href="qstring.html">QString</a></span> userName;
     <span class="type"><a href="qstring.html">QString</a></span> password;
 };
 <span class="type"><a href="qlist.html">QList</a></span><span class="operator">&lt;</span>Login<span class="operator">&gt;</span> logins;
 <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>

 <span class="type"><a href="qsettings.html">QSettings</a></span> settings;
 settings<span class="operator">.</span>beginWriteArray(<span class="string">"logins"</span>);
 <span class="keyword">for</span> (<span class="type">int</span> i <span class="operator">=</span> <span class="number">0</span>; i <span class="operator">&lt;</span> logins<span class="operator">.</span>size(); <span class="operator">+</span><span class="operator">+</span>i) {
     settings<span class="operator">.</span>setArrayIndex(i);
     settings<span class="operator">.</span>setValue(<span class="string">"userName"</span><span class="operator">,</span> list<span class="operator">.</span>at(i)<span class="operator">.</span>userName);
     settings<span class="operator">.</span>setValue(<span class="string">"password"</span><span class="operator">,</span> list<span class="operator">.</span>at(i)<span class="operator">.</span>password);
 }
 settings<span class="operator">.</span><a href="qsettings.html#endArray">endArray</a>();
</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><b>See also</b> <a href="qsettings.html#beginReadArray">beginReadArray</a>(), <a href="qsettings.html#endArray">endArray</a>(), and <a href="qsettings.html#setArrayIndex">setArrayIndex</a>().</p>


<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 class="cpp">
 <span class="type"><a href="qsettings.html">QSettings</a></span> settings;
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"fridge/color"</span><span class="operator">,</span> <span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>white);
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"fridge/size"</span><span class="operator">,</span> <span class="type"><a href="qsize.html">QSize</a></span>(<span class="number">32</span><span class="operator">,</span> <span class="number">96</span>));
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"sofa"</span><span class="operator">,</span> <span class="keyword">true</span>);
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"tv"</span><span class="operator">,</span> <span class="keyword">false</span>);

 <span class="type"><a href="qstringlist.html">QStringList</a></span> groups <span class="operator">=</span> settings<span class="operator">.</span>childGroups();
 <span class="comment">// groups: ["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 class="cpp">
 settings<span class="operator">.</span><a href="qsettings.html#beginGroup">beginGroup</a>(<span class="string">"fridge"</span>);
 groups <span class="operator">=</span> settings<span class="operator">.</span>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><b>See also</b> <a href="qsettings.html#childKeys">childKeys</a>() and <a href="qsettings.html#allKeys">allKeys</a>().</p>


<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 class="cpp">
 <span class="type"><a href="qsettings.html">QSettings</a></span> settings;
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"fridge/color"</span><span class="operator">,</span> <span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>white);
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"fridge/size"</span><span class="operator">,</span> <span class="type"><a href="qsize.html">QSize</a></span>(<span class="number">32</span><span class="operator">,</span> <span class="number">96</span>));
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"sofa"</span><span class="operator">,</span> <span class="keyword">true</span>);
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"tv"</span><span class="operator">,</span> <span class="keyword">false</span>);

 <span class="type"><a href="qstringlist.html">QStringList</a></span> keys <span class="operator">=</span> settings<span class="operator">.</span>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 class="cpp">
 settings<span class="operator">.</span><a href="qsettings.html#beginGroup">beginGroup</a>(<span class="string">"fridge"</span>);
 keys <span class="operator">=</span> settings<span class="operator">.</span>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><b>See also</b> <a href="qsettings.html#childGroups">childGroups</a>() and <a href="qsettings.html#allKeys">allKeys</a>().</p>


<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><b>See also</b> <a href="qsettings.html#remove">remove</a>() and
<a href="qsettings.html#setFallbacksEnabled">setFallbacksEnabled</a>().</p>


<h3 class="fn"><a name="contains" />bool QSettings.contains (<i>self</i>, QString&#160;<i>key</i>)</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><b>See also</b> <a href="qsettings.html#value">value</a>() and
<a href="qsettings.html#setValue">setValue</a>().</p>


<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><b>See also</b> <a href="qsettings.html#setDefaultFormat">setDefaultFormat</a>() and
<a href="qsettings.html#format">format</a>().</p>


<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><b>See also</b> <a href="qsettings.html#beginReadArray">beginReadArray</a>() and <a href="qsettings.html#beginWriteArray">beginWriteArray</a>().</p>


<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 class="cpp">
 settings<span class="operator">.</span><a href="qsettings.html#beginGroup">beginGroup</a>(<span class="string">"alpha"</span>);
 <span class="comment">// settings.group() == "alpha"</span>

 settings<span class="operator">.</span><a href="qsettings.html#beginGroup">beginGroup</a>(<span class="string">"beta"</span>);
 <span class="comment">// settings.group() == "alpha/beta"</span>

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

 settings<span class="operator">.</span>endGroup();
 <span class="comment">// settings.group() == ""</span>
</pre>
<p><b>See also</b> <a href="qsettings.html#beginGroup">beginGroup</a>() and <a href="qsettings.html#group">group</a>().</p>


<h3 class="fn"><a name="event" />bool QSettings.event (<i>self</i>, <a href="qevent.html">QEvent</a>&#160;<i>event</i>)</h3><p>Reimplemented from <a href="qobject.html#event">QObject.event</a>().</p>


<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><b>See also</b> <a href="qsettings.html#setFallbacksEnabled">setFallbacksEnabled</a>().</p>


<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><b>See also</b> <a href="qsettings.html#isWritable">isWritable</a>() and <a href="qsettings.html#format">format</a>().</p>


<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><b>See also</b> <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>


<h3 class="fn"><a name="group" />QString QSettings.group (<i>self</i>)</h3><p>Returns the current group.</p>
<p><b>See also</b> <a href="qsettings.html#beginGroup">beginGroup</a>() and <a href="qsettings.html#endGroup">endGroup</a>().</p>


<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><b>See also</b> <a href="qsettings.html#setIniCodec">setIniCodec</a>().</p>


<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><b>See also</b> <a href="qsettings.html#fileName">fileName</a>(), <a href="qsettings.html#status">status</a>(), and <a href="qsettings.html#sync">sync</a>().</p>


<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><b>See also</b> <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>


<h3 class="fn"><a name="remove" />QSettings.remove (<i>self</i>, QString&#160;<i>key</i>)</h3><p>Removes the setting <i>key</i> and any sub-settings of
<i>key</i>.</p>
<p>Example:</p>
<pre class="cpp">
 <span class="type"><a href="qsettings.html">QSettings</a></span> settings;
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"ape"</span>);
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"monkey"</span><span class="operator">,</span> <span class="number">1</span>);
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"monkey/sea"</span><span class="operator">,</span> <span class="number">2</span>);
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"monkey/doe"</span><span class="operator">,</span> <span class="number">4</span>);

 settings<span class="operator">.</span>remove(<span class="string">"monkey"</span>);
 <span class="type"><a href="qstringlist.html">QStringList</a></span> keys <span class="operator">=</span> settings<span class="operator">.</span><a href="qsettings.html#allKeys">allKeys</a>();
 <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 class="cpp">
 <span class="type"><a href="qsettings.html">QSettings</a></span> settings;
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"ape"</span>);
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"monkey"</span><span class="operator">,</span> <span class="number">1</span>);
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"monkey/sea"</span><span class="operator">,</span> <span class="number">2</span>);
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"monkey/doe"</span><span class="operator">,</span> <span class="number">4</span>);

 settings<span class="operator">.</span><a href="qsettings.html#beginGroup">beginGroup</a>(<span class="string">"monkey"</span>);
 settings<span class="operator">.</span>remove(<span class="string">""</span>);
 settings<span class="operator">.</span><a href="qsettings.html#endGroup">endGroup</a>();

 <span class="type"><a href="qstringlist.html">QStringList</a></span> keys <span class="operator">=</span> settings<span class="operator">.</span><a href="qsettings.html#allKeys">allKeys</a>();
 <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><b>See also</b> <a href="qsettings.html#setValue">setValue</a>(), <a href="qsettings.html#value">value</a>(), and <a href="qsettings.html#contains">contains</a>().</p>


<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><b>See also</b> <a href="qsettings.html#format">format</a>(),
<a href="qsettings.html#organizationName">organizationName</a>(),
and <a href="qsettings.html#applicationName">applicationName</a>().</p>


<h3 class="fn"><a name="setArrayIndex" />QSettings.setArrayIndex (<i>self</i>, int&#160;<i>i</i>)</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>


<h3 class="fn"><a name="setDefaultFormat" />QSettings.setDefaultFormat (<a href="qsettings.html#Format-enum">Format</a>&#160;<i>format</i>)</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><b>See also</b> <a href="qsettings.html#defaultFormat">defaultFormat</a>() and <a href="qsettings.html#format">format</a>().</p>


<h3 class="fn"><a name="setFallbacksEnabled" />QSettings.setFallbacksEnabled (<i>self</i>, bool&#160;<i>b</i>)</h3><p>Sets whether fallbacks are enabled to <i>b</i>.</p>
<p>By default, fallbacks are enabled.</p>
<p><b>See also</b> <a href="qsettings.html#fallbacksEnabled">fallbacksEnabled</a>().</p>


<h3 class="fn"><a name="setIniCodec" />QSettings.setIniCodec (<i>self</i>, <a href="qtextcodec.html">QTextCodec</a>&#160;<i>codec</i>)</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><b>See also</b> <a href="qsettings.html#iniCodec">iniCodec</a>().</p>


<h3 class="fn"><a name="setIniCodec-2" />QSettings.setIniCodec (<i>self</i>, str&#160;<i>codecName</i>)</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><b>See also</b> <a href="qtextcodec.html#codecForName">QTextCodec.codecForName</a>().</p>


<h3 class="fn"><a name="setPath" />QSettings.setPath (<a href="qsettings.html#Format-enum">Format</a>&#160;<i>format</i>, <a href="qsettings.html#Scope-enum">Scope</a>&#160;<i>scope</i>, QString&#160;<i>path</i>)</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>
<table class="generic">
<thead>
<tr class="qt-style">
<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>
<tr class="odd" valign="top">
<td rowspan="2">Symbian</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>c:/data/.config</tt></td>
</tr>
<tr class="even" valign="top">
<td><a href="qsettings.html#Scope-enum">SystemScope</a></td>
<td><tt>&lt;drive&gt;/private/&lt;uid&gt;</tt></td>
</tr>
</table>
<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><b>See also</b> <a href="qsettings.html#registerFormat">registerFormat</a>().</p>


<h3 class="fn"><a name="setSystemIniPath" />QSettings.setSystemIniPath (QString&#160;<i>dir</i>)</h3><h3 class="fn"><a name="setUserIniPath" />QSettings.setUserIniPath (QString&#160;<i>dir</i>)</h3><h3 class="fn"><a name="setValue" />QSettings.setValue (<i>self</i>, QString&#160;<i>key</i>, QVariant&#160;<i>value</i>)</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 class="cpp">
 <span class="type"><a href="qsettings.html">QSettings</a></span> settings;
 settings<span class="operator">.</span>setValue(<span class="string">"interval"</span><span class="operator">,</span> <span class="number">30</span>);
 settings<span class="operator">.</span><a href="qsettings.html#value">value</a>(<span class="string">"interval"</span>)<span class="operator">.</span>toInt();     <span class="comment">// returns 30</span>

 settings<span class="operator">.</span>setValue(<span class="string">"interval"</span><span class="operator">,</span> <span class="number">6.55</span>);
 settings<span class="operator">.</span><a href="qsettings.html#value">value</a>(<span class="string">"interval"</span>)<span class="operator">.</span>toDouble();  <span class="comment">// returns 6.55</span>
</pre>
<p><b>See also</b> <a href="qsettings.html#value">value</a>(),
<a href="qsettings.html#remove">remove</a>(), and <a href="qsettings.html#contains">contains</a>().</p>


<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><b>See also</b> <a href="qsettings.html#sync">sync</a>().</p>


<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><b>See also</b> <a href="qsettings.html#status">status</a>().</p>


<h3 class="fn"><a name="value" />object QSettings.value (<i>self</i>, QString&#160;<i>key</i>, QVariant&#160;<i>defaultValue</i>&#160;=&#160;QVariant(), object&#160;<i>type</i>&#160;=&#160;None)</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 class="cpp">
 <span class="type"><a href="qsettings.html">QSettings</a></span> settings;
 settings<span class="operator">.</span><a href="qsettings.html#setValue">setValue</a>(<span class="string">"animal/snake"</span><span class="operator">,</span> <span class="number">58</span>);
 settings<span class="operator">.</span>value(<span class="string">"animal/snake"</span><span class="operator">,</span> <span class="number">1024</span>)<span class="operator">.</span>toInt();   <span class="comment">// returns 58</span>
 settings<span class="operator">.</span>value(<span class="string">"animal/zebra"</span><span class="operator">,</span> <span class="number">1024</span>)<span class="operator">.</span>toInt();   <span class="comment">// returns 1024</span>
 settings<span class="operator">.</span>value(<span class="string">"animal/zebra"</span>)<span class="operator">.</span>toInt();         <span class="comment">// returns 0</span>
</pre>
<p><b>See also</b> <a href="qsettings.html#setValue">setValue</a>(), <a href="qsettings.html#contains">contains</a>(), and <a href="qsettings.html#remove">remove</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.10.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> 2012</td><td align="right" width="25%">Qt&#160;4.8.5</td></tr></table></div></address></body></html>