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
qtquick-for-android.qdoc
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5 \title Qt Quick for Android
6 \brief An overview on using QML in native Android projects.
7 \page qtquick-for-android.html
8 \ingroup android-platform-extra-topics
9
10 \section1 Qt Quick for Android overview
11
12 The basis of this approach is to offer Qt QML APIs in an embedded way so
13 that the app will remain a relatively typical Android app. This approach
14 offers a more standard Android-centered approach at the cost of leveraging
15 the cross-platform nature of a Qt application. It's best suited for adding
16 desirable Qt features to an existing Android application.
17
18 \list
19 \li Android creates the Qt content and controls it.
20 \li Android Studio with the \l{\QtTAS} plugin is used for development.
21 \li For Qt content, Qt Creator or Qt Design Studio are used.
22 \li Main languages are Java and Kotlin, with QML used for specific parts
23 such as 3D content.
24 \li You can use any Android APIs you want, but you can use JNI if you want more
25 control over communication between your Java code and QML. See \l{QJniObject}
26 and \l{QJniEnvironment}.
27 \endlist
28
29 \section2 How this differs from Qt for Android
30
31 The most prominent difference between these approaches is the project structure.
32 Qt for Android applications are CMake projects that can be built for Android or
33 other platforms, while a Qt Quick for Android Project is an Android project that
34 includes QML content and can only be built for Android.
35
36 \image qtquick-for-android-comparisson.drawio.svg
37
38 The main objective of the Qt for Android approach is to let Qt handle most of the work
39 of the architecture and boilerplate code of the app and let you focus on the
40 content. It offers a complete and reliable cross-platform approach.
41
42 \list
43 \li Qt creates and controls the Android app.
44 \li \l{\QC Documentation}{\QC}, \l{Qt Design Studio}, or Visual Studio
45 can be used.
46 \li Main languages are C++ and QML.
47 \li Android specifics are more hidden; Qt handles these internally.
48 \li To use Android APIs not yet available as Qt APIs, you must use JNI.
49 See \l{QJniObject} and \l{QJniEnvironment}.
50 \endlist
51
52 See \l{How Qt for Android Works} for further details on Qt for Android's architecture.
53
54 \section1 How Qt Quick for Android works
55
56 Qt Quick for Android offers you \l{Qt Quick Android Classes}{Android APIs} that enable
57 you to insert QML content as an \l{Android: View}{Android View} in your project.
58
59 \image qtquick-for-android-architecture.drawio.svg
60
61 \section1 APIs
62 \target Android Classes
63 These are the public Java and Kotlin APIs that you will use in an Android
64 app to embed QML.
65
66 \section2 Java classes
67
68 \list
69 \li \l{QtQuickView}
70 \li \l{QtQuickViewContent}
71 \li \l{QtAbstractItemModel}
72 \li \l{QtAbstractListModel}
73 \li \l{QtModelIndex}
74 \endlist
75
76 \section2 Interfaces
77
78 \list
79 \li \l{QtQmlStatusChangeListener} (which uses the \l QtQmlStatus enum)
80 \endlist
81
82 \note See the \l{QT_ANDROID_GENERATE_JAVA_QTQUICKVIEW_CONTENTS} CMake
83 variable for further information on Java code generation of QML components.
84
85 \section1 API examples
86
87 \list
88 \li \l{Qt Quick for Android Studio Projects}
89 \li \l{Exposing QtAbstractListModel to QML}
90 \li \l{Using QtAbstractItemModel in Android Studio Projects}
91 \endlist
92
93 \include qtquick-for-android-main().qdocinc
94
95 \section2 Running Qt Quick for Android examples
96
97 \include running-qtquick-for-android-examples.qdocinc
98
99 \section1 Tooling
100
101 The \l{Qt Gradle Plugin} and \l{\QtTAS} plugin are provided by Qt for easy
102 development. You can use the Gradle Plugin independently from an IDE as part
103 of your build toolchain. \QtTAS uses the plugin to build your projects in
104 Android Studio.
105
106 \section1 Where to go from here
107
108 The following additional topics apply to Qt Quick For Android:
109
110 \annotatedlist qq4a-extra-topics
111
112*/