This file is indexed.

/usr/share/qt5/doc/qtdoc/qtquick-deployment.html is in qt5-doc-html 5.9.5-0ubuntu1.

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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- deployment.qdoc -->
  <title>Deploying QML Applications | Qt 5.9</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="index.html">Qt 5.9</a></td><td >Deploying QML Applications</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.5 Reference Documentation</td>
        </tr></table>
      </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="#deploying-applications-with-qt-creator">Deploying Applications with Qt Creator</a></li>
<li class="level1"><a href="#qml-caching">QML Caching</a></li>
<li class="level1"><a href="#qml-caching-for-deployment-preview">QML Caching for Deployment (Preview)</a></li>
<li class="level2"><a href="#limitations">Limitations</a></li>
<li class="level1"><a href="#prototyping-with-qml-scene">Prototyping with QML Scene</a></li>
<li class="level1"><a href="#initializing-the-qml-runtime-in-applications">Initializing the QML Runtime in Applications</a></li>
<li class="level2"><a href="#initializing-with-qquickview">Initializing with QQuickView</a></li>
<li class="level2"><a href="#creating-a-qqmlengine-directly">Creating a QQmlEngine directly</a></li>
<li class="level1"><a href="#managing-resource-files-with-the-qt-resource-system">Managing Resource Files with the Qt Resource System</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Deploying QML Applications</h1>
<span class="subtitle"></span>
<!-- $$$qtquick-deployment.html-description -->
<div class="descr"> <a name="details"></a>
<p>QML documents are loaded and executed by the QML runtime. This includes the Declarative UI engine along with the built-in QML types and plugin modules, and it also provides access to third-party QML types and modules.</p>
<p>Applications that use QML need to invoke the QML runtime in order to execute QML documents. This can be done by creating a <a href="../qtquick/qquickview.html">QQuickView</a> or a <a href="../qtqml/qqmlengine.html">QQmlEngine</a>, as described below. In addition, the Declarative UI package includes the qmlscene tool, which loads <code>.qml</code> files. This tool is useful for developing and testing QML code without the need to write a C++ application to load the QML runtime.</p>
<a name="deploying-applications-with-qt-creator"></a>
<h2 id="deploying-applications-with-qt-creator">Deploying Applications with Qt Creator</h2>
<p><a href="http://doc.qt.io/qtcreator/index.html">Qt Creator</a> deploys and packages QML applications to various platforms. For mobile devices, Qt Creator can directly bundle applications to the respective platform package formats such as APK.</p>
<p>For more information, visit:</p>
<ul>
<li><a href="deployment.html">Deploying Qt Applications</a></li>
<li><a href="http://doc.qt.io/qtcreator/creator-running-targets.html">Running on Multiple Platforms</a></li>
<li><a href="http://doc.qt.io/qtcreator/creator-deployment.html">Deploying to Devices</a></li>
</ul>
<p>When running applications on the target platform, the application needs to access the location of the QML libraries. When using <a href="../qmake/qmake-manual.html">qmake</a>, the <code>QT_INSTALL_QML</code> environment points to the location of the libraries. The <a href="http://qt.io/download">Qt Installers</a> install the QML libraries in <i>&lt;version&gt;</i><code>/</code><i>&lt;compiler&gt;</i><code>/qml</code> directory.</p>
<a name="qml-caching"></a>
<h2 id="qml-caching">QML Caching</h2>
<p>The QML runtime loads QML documents by parsing them and generating native code. Most of the time the document hasn't changed since the last time it was loaded. In order to speed up this loading process, the QML runtime maintains a cache file for each qml document. This cache file contains the native code and a binary representation of the QML document structure. In addition, when multiple applications use the same QML document, the memory needed for the code is shared between application processes. The cache files are loaded via the <code>mmap()</code> system call on POSIX compliant operating systems or <code>CreateFileMapping()</code> on Windows, resulting in significant memory savings.</p>
<p>Each time you load a changed QML document, the cache is automatically re-created. Cache files are located in the same directory as the source code, if the directory is writable. Otherwise they will be placed in a sub-directory of <a href="../qtcore/qstandardpaths.html#StandardLocation-enum">QStandardPaths::CacheLocation</a> with the name &quot;qmlcache&quot;. The file extension is <code>.qmlc</code> for QML documents and <code>.jsc</code> for imported JavaScript modules. On the Android platform, cache files are always stored in the cache directory.</p>
<a name="qml-caching-for-deployment-preview"></a>
<h2 id="qml-caching-for-deployment-preview">QML Caching for Deployment (Preview)</h2>
<p>The automatic caching of QML documents into cache files result in significantly faster load times of applications. However, the initial creation of cache files can still take time, especially when the application starts first. To avoid that initial step and provide faster start-up times from the very beginning, Qt's build system allows you to create these cache files in advance.</p>
<p>If you would like to deploy your application with cache files generated ahead of time, you must satisfy four conditions in your <code>.pro</code> file:</p>
<ul>
<li>All QML documents (including JavaScript files) must be added to the <code>QML_FILES</code> variable.</li>
<li>Your .pro file must use the <code>load(qml_module)</code> or <code>load(qml_plugin)</code> directive at the end, to activate the processing of <code>QML_FILES</code> and generation of install rules.</li>
<li>The <code>TARGETPATH</code> variable must contain the import name of your QML module with forward slashes as separators.</li>
<li>You must enable Ahead-of-Time caching using the <code>CONFIG+=qmlcache</code> directive.</li>
</ul>
<p>For example if you are developing the module <code>MyCompany.CommonComponents</code>, then your <code>.pro</code> file could look like this:</p>
<pre class="cpp">

  TARGETPATH <span class="operator">=</span> MyCompany<span class="operator">/</span>CommonComponents
  QML_FILES <span class="operator">=</span> BlueButton<span class="operator">.</span>qml RedSlider<span class="operator">.</span>qml qmldir
  CONFIG <span class="operator">+</span><span class="operator">=</span> qmlcache
  load(qml_module)

</pre>
<p>Similarly, if your module contains a C++ plugin then you use <code>qml_plugin</code>:</p>
<pre class="cpp">

  TARGETPATH <span class="operator">=</span> MyCompany<span class="operator">/</span>CommonComponents
  QML_FILES <span class="operator">=</span> BlueButton<span class="operator">.</span>qml RedSlider<span class="operator">.</span>qml qmldir
  CONFIG <span class="operator">+</span><span class="operator">=</span> qmlcache
  SOURCES <span class="operator">=</span> plugin<span class="operator">.</span>cpp
  QT <span class="operator">+</span><span class="operator">=</span> quick
  load(qml_plugin)

</pre>
<p>In these examples the QML module consisting of the QML documents, the <code>qmldir</code> file, and optionally the C++ plugin, will be installed into the MyCompany/CommonComponents sub-directory of <code>$$[QT_INSTALL_QML]</code>. By enabling the <code>qmlcache</code> configuration, the cache files will be created at build time and also installed into the same directory for deployment.</p>
<a name="limitations"></a>
<h3 >Limitations</h3>
<p>Currently this feature has some limitations:</p>
<ul>
<li>Only QML and JavaScript documents that are part of a QML module can be compiled ahead of time.</li>
<li>For cross-compilation, only the ARMv7 and ARMv8 target architectures are supported.</li>
<li>For native compilation, Ahead-of-Time caching is limited to architectures where the QML runtime supports Just-in-Time compilation. This includes x86, x86-64, ARMv7, ARMv8 and MIPS32.</li>
</ul>
<a name="prototyping-with-qml-scene"></a>
<h2 id="prototyping-with-qml-scene">Prototyping with QML Scene</h2>
<p>The Declarative UI package includes a QML runtime tool, <a href="qtquick-qmlscene.html">qmlscene</a>, which loads and displays QML documents. This is useful during the application development phase for prototyping QML-based applications without writing your own C++ applications to invoke the QML runtime.</p>
<a name="initializing-the-qml-runtime-in-applications"></a>
<h2 id="initializing-the-qml-runtime-in-applications">Initializing the QML Runtime in Applications</h2>
<p>To run an application that uses QML, the QML runtime must be invoked by the application. This is done by writing a Qt C++ application that loads the <a href="../qtqml/qqmlengine.html">QQmlEngine</a> by either:</p>
<ul>
<li>Loading the QML file through a <a href="../qtquick/qquickview.html">QQuickView</a> instance, or</li>
<li>Creating a <a href="../qtqml/qqmlengine.html">QQmlEngine</a> instance and loading QML files with <a href="../qtqml/qqmlcomponent.html">QQmlComponent</a></li>
</ul>
<a name="initializing-with-qquickview"></a>
<h3 >Initializing with QQuickView</h3>
<p><a href="../qtquick/qquickview.html">QQuickView</a> is a <a href="../qtgui/qwindow.html">QWindow</a>-based class that is able to load QML files. For example, if there is a QML file, <code>application.qml</code>, it will look like this:</p>
<pre class="qml">

  import QtQuick 2.3

  <span class="type"><a href="../qtquick/qml-qtquick-rectangle.html">Rectangle</a></span> { <span class="name">width</span>: <span class="number">100</span>; <span class="name">height</span>: <span class="number">100</span>; <span class="name">color</span>: <span class="string">&quot;red&quot;</span> }

</pre>
<p>It can be loaded in a Qt application's <code>main.cpp</code> file like this:</p>
<pre class="cpp">

  <span class="preprocessor">#include &lt;QGuiApplication&gt;</span>
  <span class="preprocessor">#include &lt;QQuickView&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="type"><a href="../qtgui/qguiapplication.html">QGuiApplication</a></span> app(argc<span class="operator">,</span> argv);

      <span class="type"><a href="../qtquick/qquickview.html">QQuickView</a></span> view;
      view<span class="operator">.</span>setSource(<span class="type"><a href="../qtcore/qurl.html">QUrl</a></span><span class="operator">::</span>fromLocalFile(<span class="string">&quot;application.qml&quot;</span>));
      view<span class="operator">.</span>show();

      <span class="keyword">return</span> app<span class="operator">.</span>exec();
  }

</pre>
<p>This creates a <a href="../qtgui/qwindow.html">QWindow</a>-based view that displays the contents of <code>application.qml</code>.</p>
<p>The application's <code>.pro</code> <a href="../qmake/qmake-project-files.html">project file</a> must specify the <code>declarative</code> module for the <code>QT</code> variable. For example:</p>
<pre class="cpp">

  TEMPLATE <span class="operator">+</span><span class="operator">=</span> app
  QT <span class="operator">+</span><span class="operator">=</span> quick
  SOURCES <span class="operator">+</span><span class="operator">=</span> main<span class="operator">.</span>cpp

</pre>
<a name="creating-a-qqmlengine-directly"></a>
<h3 >Creating a QQmlEngine directly</h3>
<p>If <code>application.qml</code> does not have any graphical components, or if it is preferred to avoid <a href="../qtquick/qquickview.html">QQuickView</a> for other reasons, the <a href="../qtqml/qqmlengine.html">QQmlEngine</a> can be constructed directly instead. In this case, <code>application.qml</code> is loaded as a <a href="../qtqml/qqmlcomponent.html">QQmlComponent</a> instance rather than placed into a view:</p>
<pre class="cpp">

  <span class="preprocessor">#include &lt;QGuiApplication&gt;</span>
  <span class="preprocessor">#include &lt;QQmlEngine&gt;</span>
  <span class="preprocessor">#include &lt;QQmlContext&gt;</span>
  <span class="preprocessor">#include &lt;QQmlComponent&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="type"><a href="../qtgui/qguiapplication.html">QGuiApplication</a></span> app(argc<span class="operator">,</span> argv);

      <span class="type"><a href="../qtqml/qqmlengine.html">QQmlEngine</a></span> engine;
      <span class="type"><a href="../qtqml/qqmlcontext.html">QQmlContext</a></span> <span class="operator">*</span>objectContext <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtqml/qqmlcontext.html">QQmlContext</a></span>(engine<span class="operator">.</span>rootContext());

      <span class="type"><a href="../qtqml/qqmlcomponent.html">QQmlComponent</a></span> component(<span class="operator">&amp;</span>engine<span class="operator">,</span> <span class="string">&quot;application.qml&quot;</span>);
      <span class="type"><a href="../qtcore/qobject.html">QObject</a></span> <span class="operator">*</span>object <span class="operator">=</span> component<span class="operator">.</span>create(objectContext);

      <span class="comment">// ... delete object and objectContext when necessary</span>

      <span class="keyword">return</span> app<span class="operator">.</span>exec();
  }

</pre>
<p><a href="../qtgui/qguiapplication.html">QGuiApplication</a> can be replaced by a <a href="../qtcore/qcoreapplication.html">QCoreApplication</a> in the code above in case you are not using any graphical items from Qt Quick. This allows using QML as a language without any dependencies to the <a href="../qtgui/qtgui-index.html">Qt GUI</a> module.</p>
<p>See <a href="../qtqml/qtqml-cppintegration-data.html">qtqml-cppintegration-exposecppattributes.html</a>{Exposing Attributes of C++ Types to QML} for more information about using <a href="../qtqml/qqmlengine.html">QQmlEngine</a>, <a href="../qtqml/qqmlcontext.html">QQmlContext</a> and <a href="../qtqml/qqmlcomponent.html">QQmlComponent</a>, as well as details on including QML files through <a href="../qtcore/resources.html">Qt's Resource system</a>.</p>
<a name="managing-resource-files-with-the-qt-resource-system"></a>
<h2 id="managing-resource-files-with-the-qt-resource-system">Managing Resource Files with the Qt Resource System</h2>
<p>The <a href="../qtcore/resources.html">Qt resource system</a> allows resource files to be stored as binary files in an application executable. This can be useful when building a mixed QML/C++ application as it enables QML files (as well as other resources such as images and sound files) to be referred to through the resource system URI scheme rather than relative or absolute paths to filesystem resources. Note, however, that if you use the resource system, the application executable must be re-compiled whenever a QML source file is changed in order to update the resources in the package.</p>
<p>To use the resource system in a mixed QML/C++ application:</p>
<ul>
<li>Create a <code>.qrc</code> <a href="../qtcore/resources.html">resource collection file</a> that lists resource files in XML format</li>
<li>From C++, load the main QML file as a resource using the <code>:/</code> prefix or as a URL with the <code>qrc</code> scheme</li>
</ul>
<p>Once this is done, all files specified by relative paths in QML will be loaded from the resource system instead. Use of the resource system is completely transparent to the QML layer; this means all QML code should refer to resource files using relative paths and should <i>not</i> use the <code>qrc</code> scheme. This scheme should only be used from C++ code for referring to resource files.</p>
<p>Here is a application packaged using the <a href="../qtcore/resources.html">Qt resource system</a>. The directory structure looks like this:</p>
<pre class="cpp">

  project
      <span class="operator">|</span><span class="operator">-</span> example<span class="operator">.</span>qrc
      <span class="operator">|</span><span class="operator">-</span> main<span class="operator">.</span>qml
      <span class="operator">|</span><span class="operator">-</span> images
          <span class="operator">|</span><span class="operator">-</span> background<span class="operator">.</span>png
      <span class="operator">|</span><span class="operator">-</span> main<span class="operator">.</span>cpp
      <span class="operator">|</span><span class="operator">-</span> project<span class="operator">.</span>pro

</pre>
<p>The <code>main.qml</code> and <code>background.png</code> files will be packaged as resource files. This is done in the <code>example.qrc</code> resource collection file:</p>
<pre class="cpp">

  &lt;!DOCTYPE RCC&gt;
  &lt;RCC version=&quot;1.0&quot;&gt;

  &lt;qresource prefix=&quot;/&quot;&gt;
      &lt;file&gt;main.qml&lt;/file&gt;
      &lt;file&gt;images/background.png&lt;/file&gt;
  &lt;/qresource&gt;

  &lt;/RCC&gt;

</pre>
<p>Since <code>background.png</code> is a resource file, <code>main.qml</code> can refer to it using the relative path specified in <code>example.qrc</code>:</p>
<pre class="qml">

  <span class="comment">// main.qml</span>
  import QtQuick 2.3

  <span class="type"><a href="../qtquick/qml-qtquick-image.html">Image</a></span> { <span class="name">source</span>: <span class="string">&quot;images/background.png&quot;</span> }

</pre>
<p>To allow QML to locate resource files correctly, the <code>main.cpp</code> loads the main QML file, <code>main.qml</code>, as a resource file using the <code>qrc</code> scheme:</p>
<pre class="cpp">

  <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"><a href="../qtwidgets/qapplication.html">QApplication</a></span> app(argc<span class="operator">,</span> argv);

      <span class="type"><a href="../qtquick/qquickview.html">QQuickView</a></span> view;
      view<span class="operator">.</span>setSource(<span class="type"><a href="../qtcore/qurl.html">QUrl</a></span>(<span class="string">&quot;qrc:/main.qml&quot;</span>));
      view<span class="operator">.</span>show();

      <span class="keyword">return</span> app<span class="operator">.</span>exec();
  }

</pre>
<p>Finally, <code>project.pro</code> uses the RESOURCES variable to indicate that <code>example.qrc</code> should be used to build the application resources:</p>
<pre class="cpp">

  QT += qml

  SOURCES += main.cpp
  RESOURCES += example.qrc

</pre>
<p>See <a href="../qtcore/resources.html">The Qt Resource System</a> for more information.</p>
</div>
<!-- @@@qtquick-deployment.html -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 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>