Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
deployment.qdoc
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\page qtquick-deployment.html
6\meta {keywords} {qmltopic}
7\title Deploying QML Applications
8\brief Provides information on how to use deploy QML applications.
9
10This page provides information on how to deploy QML applications. It covers the
11use of \QC for deployment, and the use of the Qt Resource System to package QML
12files and other resources with the application executable.
13
14\section1 Deploying applications with \QC
15
16\l{\QC Documentation}{\QC} deploys and packages QML applications to various
17platforms. For mobile devices, \QC can directly bundle applications to the
18respective platform package formats, such as APK.
19
20When you run your applications on the target platform, your application needs
21to access the location of the QML libraries. If you use
22\l{qmake Manual}{qmake}, the \c QT_INSTALL_QML environment variable points to
23the location of the libraries. The \l{Downloads}{Qt Installers} install the QML
24libraries in: \c{<version>}\c{/}\e{<compiler>}\c{/qml} directory.
25
26
27\section1 Using the Qt Resource System with QML
28
29The \l {The Qt Resource System}{Qt resource system} allows resource files to be
30stored as binary files in an application executable. The Qt Resource System is
31used for QML application as it enables QML files and other resources -- such as
32images and sound files -- to be referred to through the resource system URI
33scheme rather than relative or absolute paths to filesystem resources.
34
35\note Usage of the resource system means that the application executable
36usually must be re-compiled whenever a QML source file is changed, to update
37the resources in the package.
38
39The \l{qt_add_qml_module}{CMake QML Module API} automatically places your QML
40files in the resource system. To access them, load your main QML file as a
41resource or as a URL with the \c{qrc} scheme. The path in the resource system
42where your QML files are placed can be found by concatenating:
43
44\list
45\li the \c RESOURCE_PREFIX you have passed to \l{qt_add_qml_module}.
46\li \c{/qt/qml}, if you have \e{not} passed \c RESOURCE_PREFIX to
47 \l{qt_add_qml_module} and \l{QTP0001} policy is set to \c NEW.
48\li \c{/}, if you have \e{not} passed \c RESOURCE_PREFIX to \l{qt_add_qml_module}
49 and \l{QTP0001} policy is \c{not} set to \c NEW.
50\li If you have \e{not} passed \c NO_RESOURCE_TARGET_PATH to \l{qt_add_qml_module}:
51 the \c URI you have passed to \l{qt_add_qml_module} with dots replaced by slashes.
52\endlist
53
54For example, a module called \c{My.Own.Module} is placed at:
55\list
56\li \c{:/qt/qml/My/Own/Module/} if you have specified \c{/qt/qml} as \c RESOURCE_PREFIX, or
57 you have \e{not} passed \c RESOURCE_PREFIX and \l{QTP0001} policy is set to \c NEW.
58\li \c{:/My/Own/Module/} if you have specified \c{/} as \c RESOURCE_PREFIX, or
59 you have \e{not} passed \c RESOURCE_PREFIX and \l{QTP0001} policy is \e{not} set to \c NEW.
60\li \c{:/Some/Prefix/My/Own/Module/} if you have specified \c{Some/Prefix/} as \c RESOURCE_PREFIX
61\li \c{:/} if you have specified \c NO_RESOURCE_TARGET_PATH
62\endlist
63
64Once this is done, all files specified by relative paths in QML are loaded from
65the resource system. Use of the resource system is completely transparent to
66the QML layer; this means all QML code should refer to resource files using
67relative paths and should \e{not} use the \c{qrc} scheme. This scheme should
68only be used from C++ code to refer to resource files.
69
70\note When using qmake, you need to manually place your files in the resource
71system. See the \l{qmake Manual} and the \l{The Qt Resource System}{general
72documentation} on the resource system for how to do this. It's advisable to
73still follow the path naming convention outlined above.
74
75\section1 Related Information
76\list
77 \li \l{Deploying Qt Applications}
78 \li \l{\QC: Run on many platforms}
79 \li \l{Data Type Conversion Between QML and C++}{Exposing Attributes of C++ Types to QML}
80 \li \l{The Qt Resource System}
81\endlist
82
83*/