summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2023-07-08 15:16:12 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2023-07-10 11:34:41 +0200
commit6ec35ff8c56222a317b838b6aac390eb6974de85 (patch)
tree64074b94cf024fd12c48b57a0cb8e7d88874e422
parent60f706063aebee22f7fc1bb80f0003afb50fe73e (diff)
a11y: Report app as parent for top-level item views
As happens for other widgets (s. QAccessibleWidget::parentObject), report the app as accessible parent for item views that don't have another parent set. Otherwise, the accessible tree is broken when there's a top-level item view: The application has the item view as a child, but the child does not have any parent set. Extend a QListView autotest accordingly. Fixes: QTBUG-115135 Pick-to: 6.6 6.5 Change-Id: Ie06874681180a30fc6248dc98f80c4158d837278 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--src/widgets/accessible/itemviews.cpp2
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp6
2 files changed, 7 insertions, 1 deletions
diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp
index ae1de6cab4..e640194a2e 100644
--- a/src/widgets/accessible/itemviews.cpp
+++ b/src/widgets/accessible/itemviews.cpp
@@ -557,7 +557,7 @@ QAccessibleInterface *QAccessibleTable::parent() const
}
return QAccessible::queryAccessibleInterface(view()->parent());
}
- return nullptr;
+ return QAccessible::queryAccessibleInterface(qApp);
}
QAccessibleInterface *QAccessibleTable::child(int logicalIndex) const
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index bc19ca4470..2fe8e0e5bd 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -2878,6 +2878,12 @@ void tst_QAccessibility::listTest()
QCOMPARE(iface->indexOfChild(child3), 2);
QCOMPARE(child3->text(QAccessible::Name), QString("Brisbane"));
}
+
+ // Check that application is accessible parent, since it's a top-level widget
+ QAccessibleInterface *parentIface = iface->parent();
+ QVERIFY(parentIface);
+ QVERIFY(parentIface->role() == QAccessible::Application);
+
QTestAccessibility::clearEvents();
// Check for events