Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qohosnativeinterface.cpp
Go to the documentation of this file.
1
// Copyright (C) 2026 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
include
<
QtGui
/
qwindow
.
h
>
6
#
include
<
QtGui
/
qpa
/
qplatformscreen_p
.
h
>
7
#
include
<
QtGui
/
qpa
/
qplatformwindow_p
.
h
>
8
#
include
<
QtGui
/
qpa
/
qplatformintegration
.
h
>
9
#
include
<
QtGui
/
private
/
qguiapplication_p
.
h
>
10
11
QT_BEGIN_NAMESPACE
12
13
using
namespace
QNativeInterface::Private;
14
15
/*!
16
\class QNativeInterface::Private::QOhosScreen
17
\since 6.12
18
\internal
19
\brief Native interface to a screen on OpenHarmony.
20
\inmodule QtGui
21
\ingroup native-interfaces
22
*/
23
QT_DEFINE_PRIVATE_NATIVE_INTERFACE
(
QOhosScreen
);
24
25
/*!
26
\class QNativeInterface::Private::QOhosWindow
27
\since 6.12
28
\internal
29
\brief Native interface to a window on OpenHarmony.
30
\inmodule QtGui
31
\ingroup native-interfaces
32
*/
33
QT_DEFINE_PRIVATE_NATIVE_INTERFACE
(
QOhosWindow
);
34
QT_DEFINE_PRIVATE_NATIVE_INTERFACE
(
QOhosIntegration
);
35
36
/*!
37
\class QNativeInterface::QHarmonyWindow
38
\brief Native interface to a window on HarmonyOS.
39
40
Accessed through QWindow::nativeInterface().
41
42
On HarmonyOS, an ArkTS \c UIAbility instance shows a top-level QWindow
43
in a \c window.Window. Platform APIs that are bound to a window need
44
these objects, for example a picker that opens over the window, or an
45
ability started from it. This interface provides them as
46
QHarmonyJsObjectRef handles, which you dereference on the JS thread.
47
Only top-level windows are shown this way. For a child window, both
48
functions return null references. Use the interface of its top-level
49
window instead.
50
51
Both functions return at once, without waiting for the JS thread. The
52
objects are available when QWindow::show() returns and stay the same
53
while the window stays visible and top-level. After the window is
54
hidden or reparented, the functions may return null references.
55
Showing the window again, or recreating it with QWindow::destroy()
56
and show(), may give different objects.
57
58
This interface does not track what the platform does with the
59
objects. If the platform destroys the ability or the
60
\c window.Window, the functions may still return references to the
61
destroyed objects, and code that uses the references on the JS
62
thread must handle that.
63
64
\inmodule QtGui
65
\inheaderfile QWindow
66
\ingroup native-interfaces
67
\ingroup native-interfaces-qwindow
68
69
\sa {Qt for HarmonyOS Platform API}
70
*/
71
QT_DEFINE_NATIVE_INTERFACE
(
QHarmonyWindow
);
72
73
/*!
74
\fn QHarmonyJsObjectRef QNativeInterface::QHarmonyWindow::ability() const
75
76
Returns the \c UIAbility instance that shows the window. Returns a null
77
reference if no ability shows the window, for example if the platform
78
has not attached the window to an ability yet.
79
*/
80
81
/*!
82
\fn QHarmonyJsObjectRef QNativeInterface::QHarmonyWindow::jsWindow() const
83
84
Returns the \c window.Window that the window is shown in, or a null
85
reference if the window is not shown in one.
86
*/
87
88
QWindow *QOhosWindow::fromNative(ArkUI_NodeHandle content)
89
{
90
if
(!content)
91
return
nullptr
;
92
93
auto
*integration = QGuiApplicationPrivate::platformIntegration();
94
const
WId id = integration->call<&QOhosIntegration::windowHandle>(content);
95
return
id ? QWindow::fromWinId(id) :
nullptr
;
96
}
97
98
QT_END_NAMESPACE
QT_DEFINE_PRIVATE_NATIVE_INTERFACE
QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QOhosWindow)
QT_DEFINE_PRIVATE_NATIVE_INTERFACE
QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QOhosIntegration)
QT_DEFINE_NATIVE_INTERFACE
QT_DEFINE_NATIVE_INTERFACE(QHarmonyWindow)
QT_DEFINE_PRIVATE_NATIVE_INTERFACE
QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QOhosScreen)
qtbase
src
gui
platform
ohos
qohosnativeinterface.cpp
Generated on
for Qt by
1.18.0