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
/
qscreen
.
h
>
6
#
include
<
QtGui
/
qwindow
.
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::QOhosWindow
17
\since 6.12
18
\internal
19
\brief Native interface to a window on OpenHarmony.
20
\inmodule QtGui
21
\ingroup native-interfaces
22
*/
23
QT_DEFINE_PRIVATE_NATIVE_INTERFACE
(
QOhosWindow
);
24
QT_DEFINE_PRIVATE_NATIVE_INTERFACE
(
QOhosIntegration
);
25
26
/*!
27
\class QNativeInterface::QHarmonyScreen
28
\brief Native interface to a screen on HarmonyOS.
29
30
Accessed through QScreen::nativeInterface().
31
32
\inmodule QtGui
33
\inheaderfile QScreen
34
\ingroup native-interfaces
35
\ingroup native-interfaces-qscreen
36
37
\sa {Qt for HarmonyOS Platform API}
38
*/
39
QT_DEFINE_NATIVE_INTERFACE
(
QHarmonyScreen
);
40
41
/*!
42
\fn qint64 QNativeInterface::QHarmonyScreen::displayId() const
43
44
Returns the ID of the display that the screen represents. Platform APIs
45
that work on a display, such as those of the \c{@ohos.display} module,
46
identify it by this ID.
47
48
A screen can come to represent another display when the platform
49
reports a display change, for example when a display is added or
50
removed. The ID of a screen can therefore change over its lifetime.
51
*/
52
53
/*!
54
\class QNativeInterface::QHarmonyWindow
55
\brief Native interface to a window on HarmonyOS.
56
57
Accessed through QWindow::nativeInterface().
58
59
On HarmonyOS, an ArkTS \c UIAbility instance shows a top-level QWindow
60
in a \c window.Window. Platform APIs that are bound to a window need
61
these objects, for example a picker that opens over the window, or an
62
ability started from it. This interface provides them as
63
QHarmonyJsObjectRef handles, which you dereference on the JS thread.
64
Only top-level windows are shown this way. For a child window, both
65
functions return null references. Use the interface of its top-level
66
window instead.
67
68
Both functions return at once, without waiting for the JS thread. The
69
objects are available when QWindow::show() returns and stay the same
70
while the window stays visible and top-level. After the window is
71
hidden or reparented, the functions may return null references.
72
Showing the window again, or recreating it with QWindow::destroy()
73
and show(), may give different objects.
74
75
This interface does not track what the platform does with the
76
objects. If the platform destroys the ability or the
77
\c window.Window, the functions may still return references to the
78
destroyed objects, and code that uses the references on the JS
79
thread must handle that.
80
81
\inmodule QtGui
82
\inheaderfile QWindow
83
\ingroup native-interfaces
84
\ingroup native-interfaces-qwindow
85
86
\sa {Qt for HarmonyOS Platform API}
87
*/
88
QT_DEFINE_NATIVE_INTERFACE
(
QHarmonyWindow
);
89
90
/*!
91
\fn QHarmonyJsObjectRef QNativeInterface::QHarmonyWindow::ability() const
92
93
Returns the \c UIAbility instance that shows the window. Returns a null
94
reference if no ability shows the window, for example if the platform
95
has not attached the window to an ability yet.
96
*/
97
98
/*!
99
\fn QHarmonyJsObjectRef QNativeInterface::QHarmonyWindow::jsWindow() const
100
101
Returns the \c window.Window that the window is shown in, or a null
102
reference if the window is not shown in one.
103
*/
104
105
QWindow *QOhosWindow::fromNative(ArkUI_NodeHandle content)
106
{
107
if
(!content)
108
return
nullptr
;
109
110
auto
*integration = QGuiApplicationPrivate::platformIntegration();
111
const
WId id = integration->call<&QOhosIntegration::windowHandle>(content);
112
return
id ? QWindow::fromWinId(id) :
nullptr
;
113
}
114
115
QT_END_NAMESPACE
QT_DEFINE_NATIVE_INTERFACE
QT_DEFINE_NATIVE_INTERFACE(QHarmonyScreen)
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)
qtbase
src
gui
platform
ohos
qohosnativeinterface.cpp
Generated on
for Qt by
1.18.0