Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qaccessiblequickwidget.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 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
5
6#include "qquickwidget_p.h"
7
9
10#if QT_CONFIG(accessibility)
11
12QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
13: QAccessibleWidget(widget)
14{
15 // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
16 // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
17 // it will return the Quick item child interfaces, which is what's needed here
18 // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
19 repairWindow();
20}
21
22QAccessibleQuickWidget::~QAccessibleQuickWidget()
23{
24 QObject::disconnect(m_connection);
25}
26
27void QAccessibleQuickWidget::repairWindow()
28{
29 if (!m_accessibleWindow || !m_accessibleWindow->object()) {
30 QQuickWidget *theWidget = static_cast<QQuickWidget *>(object());
31 QQuickWindow *newOffscreen = QQuickWidgetPrivate::get(theWidget)->offscreenWindow;
32 // We use the qobject_cast here to detect that the newOffscreen is
33 // not the one getting destroyed right now.
34 if (qobject_cast<QQuickWindow *>(newOffscreen)) {
35 m_accessibleWindow.reset(new QAccessibleQuickWindow(newOffscreen));
36 m_connection = QObject::connect(newOffscreen, &QObject::destroyed, theWidget,
37 [this] { repairWindow(); });
38 }
39 }
40}
41
42QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
43{
44 return m_accessibleWindow->child(index);
45}
46
47int QAccessibleQuickWidget::childCount() const
48{
49 return m_accessibleWindow->childCount();
50}
51
52int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
53{
54 return m_accessibleWindow->indexOfChild(iface);
55}
56
57QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
58{
59 return m_accessibleWindow->childAt(x, y);
60}
61
62QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
63:QAccessibleQuickWindow(window)
64{
65
66}
67
68QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
69{
71 return nullptr;
72}
73
74int QAccessibleQuickWidgetOffscreenWindow::childCount() const
75{
76 return 0;
77}
78
79int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
80{
81 Q_UNUSED(iface);
82 return -1;
83}
84
85QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
86{
87 Q_UNUSED(x);
88 Q_UNUSED(y);
89 return nullptr;
90}
91
92#endif // accessibility
93
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
Definition qobject.cpp:3236
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
static QQuickWidgetPrivate * get(QQuickWidget *view)
The QQuickWidget class provides a widget for displaying a Qt Quick user interface.
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
QOpenGLWidget * widget
[1]
Combined button and popup list for selecting options.
GLint GLint GLint GLint GLint x
[0]
GLuint index
[2]
GLuint object
[3]
GLint y
#define Q_UNUSED(x)
aWidget window() -> setWindowTitle("New Window Title")
[2]