Qt for HarmonyOS/qtohosextras doc/Request Permission Example: Difference between revisions
Add example documentation from qdoc output (QTFOROH-2307) |
Fix example page conversion (QTFOROH-2307) |
||
| Line 11: | Line 11: | ||
'''Note: '''getInstanceForMainWindow() requires a valid [https://doc.qt.io/qt-5/qwindow.html QWindow], so the window must be shown before the context is requested. | '''Note: '''getInstanceForMainWindow() requires a valid [https://doc.qt.io/qt-5/qwindow.html QWindow], so the window must be shown before the context is requested. | ||
* [[Qt_for_HarmonyOS/qtohosextras_doc/Request_Permission_Example|abilitycontext/requestpermission/requestpermission.pro]] | * [[Qt_for_HarmonyOS/qtohosextras_doc/Request_Permission_Example|abilitycontext/requestpermission/requestpermission.pro]] | ||
[[Category:Qt for HarmonyOS]] | [[Category:Qt for HarmonyOS]] | ||
Revision as of 09:25, 16 September 2026
< Qt for HarmonyOS / qtohosextras doc
Request Permission Example
Demonstrates requesting application permissions from the user, per main window, by enum and by name.
A launcher button opens a new main window with one row per supported permission. In each row, one button requests the permission through the QOhosAbilityContext::requestPermissionFromUserIfNeeded() enum overload and the other through the string overload with the full OHOS permission name, for example ohos.permission.READ_PASTEBOARD. The per-window context is obtained with QOhosAbilityContext::getInstanceForMainWindow() after the window has been shown. Results arrive through the permissionRequestResponseReceived() and namedPermissionRequestResponseReceived() signals and are displayed with the permissionGranted and dialogShown flags of AppPermissions::PermissionResult.
Note: getInstanceForMainWindow() requires a valid QWindow, so the window must be shown before the context is requested.