summaryrefslogtreecommitdiff
path: root/examples/applicationmanager/application-features/doc/src/application-features.qdoc
blob: 78eb57b2c1ac16f4dd7b86e1b249120712681ce1 (plain)
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
/****************************************************************************
**
** Copyright (C) 2019 Luxoft Sweden AB
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Application Manager.
**
** $QT_BEGIN_LICENSE:FDL-QTAS$
** Commercial License Usage
** Licensees holding valid commercial Qt Automotive Suite licenses may use
** this file in accordance with the commercial license agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and The Qt Company.  For
** licensing terms and conditions see https://www.qt.io/terms-conditions.
** For further information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!

\example applicationmanager/application-features
\title Application Features Example
\image application-features.png
\brief Showcases client applications with various features, including a native application.
\ingroup applicationmanager-examples

\section1 Introduction

This example demonstrates how to implement some particular features you may require in an
application, such as:

\list
    \li how to implement a nested compositor
    \li how to simulate a crash and recover from it
    \li how to show multiple top-level windows simultaneously
    \li how to use the native runtime, with no QML

\endlist

Most of these features are only supported properly in
\l{Single-Process vs. Multi-Process Mode}{multi-process mode}.

\note This example focuses on the application (client) side. The \l{The System UI}{System UI}
(compositor/server) is based on the \l{Desktop System UI Example} with some modifications. Refer
to that example for more details on how to implement a System UI.

\section2 Nested Compositor

The nested compositor application shows how to implement a Wayland compositor inside an application
(Wayland client) window. The compositor is implemented in pure QML and kept to a minimum. To
display Wayland clients within this compositor, you need to set the \c WAYLAND_DISPLAY environment
variable appropriately.

To start a client with this environment variable set via command line:

\badcode
WAYLAND_DISPLAY=qtam-wayland-nested qmlscene client.qml -platform wayland
\endcode

This command only works in multi-process mode, since the nested compositor needs a real window as
its root element.

The QML code for the nested compositor application is as follows:

\quotefromfile applicationmanager/application-features/apps/compositor/compositor.qml
\skipto import QtQuick 2.11
\printuntil /^\}/

\section2 Crash Simulation and Recovery

This application provides various means to force a crash in an application, such as a segmentation
fault. It utilizes a QML plugin implemented in C++, to provide the \c Terminator QML type to
trigger crashes. The application manager then prints the cause of the crash and related
information, like a backtrace. The System UI implements a basic form of crash recovery: restarting
the application.

This application only works on multi-process mode. In single-process mode a crash affects the entire
program (the System UI).

The QML code for the crash simulation and recovery application is as follows:

\quotefromfile applicationmanager/application-features/apps/crash/crashapp.qml
\skipto import QtQuick 2.11
\printuntil case "gracefully": Terminator.exitGracefully(); break;
\printuntil /^\}/

\section2 Two Top-Level Windows

This application illustrates how you can display multiple top-level windows by having a QtObject
as the application's root element.

The QML code for the two top-level windows application is as follows:

\quotefromfile applicationmanager/application-features/apps/twins/twins.qml
\skipto import QtQuick 2.11
\printuntil Component.onCompleted: setWindowProperty("type", "pop-up");
\printuntil /^\}/

\section2 Native Widgets

This application is based on \l{QWidget}s. Compared to the other applications in this example,
which are QML applications, this one uses the native runtime. Consequently, the application's entry
point isn't a \c{main.qml} file, but an executable. This application is a basic application that
still adheres to this particular System UI. It's mean to illustrate the concept: the System UI
needs a \c type window property to differentiate between normal windows and popups.

This application only works in multi-process mode, as application processes cannot be started in
single-process mode.

The C++ code for the native widgets application is as follows:

\quotefromfile applicationmanager/application-features/native/widgets/main.cpp
\skipto #include <QApplication>
\printuntil /^\}/

\section1 Code Structure

Compared to the other Qt Application Manager Examples, which are purely based on QML, this example
requires you to build it explicitly. The code is structured in a way where the resulting application
folders only contain the artifacts necessary to run the application. Consequently, you can package
these applications and install them as well.

To build Qt Application Manager including its examples, you need to pass \c qmake the
\c{-config enable-examples} parameter For more details, see \l{build}{Build}.
*/