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
qt_add_harmonyos_permission.qdoc
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\page qt-add-harmonyos-permission.html
6\ingroup cmake-commands-qtcore
7
8\title qt_add_harmonyos_permission
9\keyword qt6_add_harmonyos_permission
10
11\summary {Adds a HarmonyOS permission to the target executable.}
12
13\include cmake-find-package-core.qdocinc
14
15\cmakecommandsince 6.12
16\preliminarycmakecommand
17\cmakecommandharmonyosonly
18
19\section1 Synopsis
20
21\badcode
22qt_add_harmonyos_permission(target
23 NAME <permission-name>
24 [REASON <reason>]
25 [USED_SCENE_ABILITIES <ability> [<ability>...]]
26 [USED_SCENE_WHEN inuse | always]
27)
28\endcode
29
30\versionlessCMakeCommandsNote qt6_add_harmonyos_permission()
31
32\section1 Description
33
34The command adds a HarmonyOS permission to the \c {target} executable. The
35permission is written into the \c {requestPermissions} array of the generated
36\c {module.json5} manifest when the HAP package is built. Use this command to
37request additional permissions on top of the default permissions contributed
38by the Qt modules your application links against.
39
40For the list of available permission names and their requirements, see the
41HarmonyOS application permission documentation.
42
43\section1 Arguments
44
45\c NAME is the permission identifier, for example
46\c {ohos.permission.CAMERA}. It is the only required argument.
47
48\c REASON is the message shown to the user when the system prompts for a
49\c user_grant permission. It accepts either a literal string or a
50\c {$string:<name>} resource reference that resolves to a localized string
51from the application's resource files. Specifying \c REASON causes a
52\c usedScene block to be emitted for the permission.
53
54\c USED_SCENE_ABILITIES is the list of abilities that use the permission. If
55omitted while a \c usedScene block is emitted, it defaults to \c QAbility,
56which is the single ability that hosts a Qt application.
57
58\c USED_SCENE_WHEN sets when the permission is accessed. The accepted values
59are \c inuse (the permission is used only while the application is in the
60foreground) and \c always (the permission is also used in the background). If
61omitted while a \c usedScene block is emitted, it defaults to \c inuse.
62
63\section1 Example
64
65\snippet cmake-macros/examples.cmake qt_add_harmonyos_permission
66
67\sa {Qt for HarmonyOS CMake API}
68*/