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
qaccessiblequickwindowcontainer.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
6
7#include <QtQuick/private/qquickwindowcontainer_p.h>
8
9QT_BEGIN_NAMESPACE
10
11#if QT_CONFIG(accessibility)
12
13QAccessibleQuickWindowContainer::QAccessibleQuickWindowContainer(QQuickWindowContainer *container)
14 : QAccessibleQuickItem(container)
15{
16}
17
18QQuickWindowContainer *QAccessibleQuickWindowContainer::container() const
19{
20 return static_cast<QQuickWindowContainer *>(object());
21}
22
23/*
24 Resolves the accessibility interface of the contained window.
25
26 Goes via accessibleRoot(), rather than querying an interface for the
27 window itself, as the latter is driven by the window's class name,
28 and not all QWindow subclasses may have one. Going via the root is
29 also the entry point the platform bridges use.
30*/
31QAccessibleInterface *QAccessibleQuickWindowContainer::accessibleRoot() const
32{
33 if (auto *item = container()) {
34 if (QWindow *window = item->containedWindow())
35 return window->accessibleRoot();
36 }
37
38 return nullptr;
39}
40
41int QAccessibleQuickWindowContainer::childCount() const
42{
43 return accessibleRoot() ? 1 : 0;
44}
45
46QAccessibleInterface *QAccessibleQuickWindowContainer::child(int index) const
47{
48 if (index == 0)
49 return accessibleRoot();
50
51 return nullptr;
52}
53
54int QAccessibleQuickWindowContainer::indexOfChild(const QAccessibleInterface *iface) const
55{
56 if (!iface)
57 return -1;
58
59 // The root is not necessarily an interface for the contained window
60 // itself. For a hosted widget window it's the interface of the widget.
61 if (QAccessibleInterface *root = accessibleRoot()) {
62 if (root->object() == iface->object())
63 return 0;
64 }
65
66 return -1;
67}
68
69QAccessibleInterface *QAccessibleQuickWindowContainer::childAt(int x, int y) const
70{
71 QAccessibleInterface *root = accessibleRoot();
72 if (!root || root->state().invisible)
73 return nullptr;
74
75 if (QAccessibleInterface *descendant = root->childAt(x, y))
76 return descendant;
77
78 return root->rect().contains(x, y) ? root : nullptr;
79}
80
81#endif // accessibility
82
83QT_END_NAMESPACE