/usr/share/qt5/doc/qtquick/qml-qt-labs-settings-settings.html is in qtdeclarative5-doc-html 5.5.1-2ubuntu6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qqmlsettings.cpp -->
<title>Settings QML Type | Qt Quick 5.5</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<ul>
<li>Qt 5.5</li>
<li><a href="qtquick-index.html">Qt Quick</a></li>
<li><a href="qtquick-qmlmodule.html">QML Types</a></li>
<li>Settings QML Type</li>
<li id="buildversion">Qt 5.5.1 Reference Documentation</li>
</ul>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#application-identifiers">Application Identifiers</a></li>
<li class="level2"><a href="#categories">Categories</a></li>
<li class="level2"><a href="#notes">Notes</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Settings QML Type</h1>
<span class="subtitle"></span>
<!-- $$$Settings-brief -->
<p>Provides persistent platform-independent application settings. <a href="#details">More...</a></p>
<!-- @@@Settings -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Import Statement:</td><td class="memItemRight bottomAlign"> import Qt.labs.settings 1.0</td></tr></table></div><ul>
<li><a href="qml-qt-labs-settings-settings-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="properties"></a>
<h2 id="properties">Properties</h2>
<ul>
<li class="fn"><b><b><a href="qml-qt-labs-settings-settings.html#category-prop">category</a></b></b> : string</li>
</ul>
<!-- $$$Settings-description -->
<a name="details"></a>
<h2 id="details">Detailed Description</h2>
</p>
<p>The Settings type provides persistent platform-independent application settings.</p>
<p><b>Note: </b>This type is made available by importing the <b>Qt.labs.settings</b> module. <i>Types in the Qt.labs module are not guaranteed to remain compatible in future versions.</i></p><p>Users normally expect an application to remember its settings (window sizes and positions, options, etc.) across sessions. The Settings type enables you to save and restore such application settings with the minimum of effort.</p>
<p>Individual setting values are specified by declaring properties within a Settings element. All basic type properties are supported. The recommended approach is to use property aliases in order to get automatic property updates both ways. The following example shows how to use Settings to store and restore the geometry of a window.</p>
<pre class="qml">import QtQuick.Window 2.1
import Qt.labs.settings 1.0
<span class="type"><a href="qml-qtquick-window-window.html">Window</a></span> {
<span class="name">id</span>: <span class="name">window</span>
<span class="name">width</span>: <span class="number">800</span>
<span class="name">height</span>: <span class="number">600</span>
<span class="type"><a href="qml-qt-labs-settings-settings.html">Settings</a></span> {
property <span class="type">alias</span> <span class="name">x</span>: <span class="name">window</span>.<span class="name">x</span>
property <span class="type">alias</span> <span class="name">y</span>: <span class="name">window</span>.<span class="name">y</span>
property <span class="type">alias</span> <span class="name">width</span>: <span class="name">window</span>.<span class="name">width</span>
property <span class="type">alias</span> <span class="name">height</span>: <span class="name">window</span>.<span class="name">height</span>
}
}</pre>
<p>At first application startup, the window gets default dimensions specified as 800x600. Notice that no default position is specified - we let the window manager handle that. Later when the window geometry changes, new values will be automatically stored to the persistent settings. The second application run will get initial values from the persistent settings, bringing the window back to the previous position and size.</p>
<p>A fully declarative syntax, achieved by using property aliases, comes at the cost of storing persistent settings whenever the values of aliased properties change. Normal properties can be used to gain more fine-grained control over storing the persistent settings. The following example illustrates how to save a setting on component destruction.</p>
<pre class="qml">import QtQuick 2.1
import Qt.labs.settings 1.0
<span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
<span class="name">id</span>: <span class="name">page</span>
<span class="name">state</span>: <span class="name">settings</span>.<span class="name">state</span>
<span class="name">states</span>: [
<span class="type"><a href="qml-qtquick-state.html">State</a></span> {
<span class="name">name</span>: <span class="string">"active"</span>
<span class="comment">// ...</span>
},
<span class="type"><a href="qml-qtquick-state.html">State</a></span> {
<span class="name">name</span>: <span class="string">"inactive"</span>
<span class="comment">// ...</span>
}
]
<span class="type"><a href="qml-qt-labs-settings-settings.html">Settings</a></span> {
<span class="name">id</span>: <span class="name">settings</span>
property <span class="type">string</span> <span class="name">state</span>: <span class="string">"active"</span>
}
<span class="name">Component</span>.onDestruction: {
<span class="name">settings</span>.<span class="name">state</span> <span class="operator">=</span> <span class="name">page</span>.<span class="name">state</span>
}
}</pre>
<p>Notice how the default value is now specified in the persistent setting property, and the actual property is bound to the setting in order to get the initial value from the persistent settings.</p>
<a name="application-identifiers"></a>
<h2 id="application-identifiers">Application Identifiers</h2>
<p>Application specific settings are identified by providing application name, organization and domain.</p>
<pre class="cpp"><span class="preprocessor">#include <QGuiApplication></span>
<span class="preprocessor">#include <QQmlApplicationEngine></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="type">QGuiApplication</span> app(argc<span class="operator">,</span> argv);
app<span class="operator">.</span>setOrganizationName(<span class="string">"Some Company"</span>);
app<span class="operator">.</span>setOrganizationDomain(<span class="string">"somecompany.com"</span>);
app<span class="operator">.</span>setApplicationName(<span class="string">"Amazing Application"</span>);
<span class="type">QQmlApplicationEngine</span> engine(<span class="string">"main.qml"</span>);
<span class="keyword">return</span> app<span class="operator">.</span>exec();
}</pre>
<p>These are typically specified in C++ in the beginning of <code>main()</code>, but can also be controlled in QML via the following properties:</p>
<ul>
<li>Qt.application.name,</li>
<li>Qt.application.organization and</li>
<li>Qt.application.domain.</li>
</ul>
<a name="categories"></a>
<h2 id="categories">Categories</h2>
<p>Application settings may be divided into logical categories by specifying a category name via the <a href="qml-qt-labs-settings-settings.html#category-prop">category</a> property. Using logical categories not only provides a cleaner settings structure, but also prevents possible conflicts between setting keys.</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
<span class="name">id</span>: <span class="name">panel</span>
<span class="name">visible</span>: <span class="number">true</span>
<span class="type"><a href="qml-qt-labs-settings-settings.html">Settings</a></span> {
<span class="name">category</span>: <span class="string">"OutputPanel"</span>
property <span class="type">alias</span> <span class="name">visible</span>: <span class="name">panel</span>.<span class="name">visible</span>
<span class="comment">// ...</span>
}
}</pre>
<p>Instead of ensuring that all settings in the application have unique names, the settings can be divided into unique categories that may then contain settings using the same names that are used in other categories - without a conflict.</p>
<a name="notes"></a>
<h2 id="notes">Notes</h2>
<p>The current implementation is based on QSettings. This imposes certain limitations, such as missing change notifications. Writing a setting value using one instance of Settings does not update the value in another Settings instance, even if they are referring to the same setting in the same category.</p>
<p>The information is stored in the system registry on Windows, and in XML preferences files on OS X. On other Unix systems, in the absence of a standard, INI text files are used. See QSettings documentation for more details.</p>
<p><b>See also </b>QSettings.</p>
<!-- @@@Settings -->
<h2>Property Documentation</h2>
<!-- $$$category -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="odd" id="category-prop"><td class="tblQmlPropNode"><p><a name="category-prop"></a><span class="name">category</span> : <span class="type">string</span></p></td></tr></table></div></div><div class="qmldoc"><p>This property holds the name of the settings category.</p>
<p>Categories can be used to group related settings together.</p>
</div></div><!-- @@@category -->
<br/>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2015 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.<br> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. </p>
</div>
</body>
</html>
|