diff options
| author | Lorn Potter <lorn.potter@qt.io> | 2026-09-15 13:22:11 +1000 |
|---|---|---|
| committer | Lorn Potter <lorn.potter@qt.io> | 2026-09-30 04:55:32 +0000 |
| commit | 6230459365de59766fc4c9eefc696a4b8ed6f97f (patch) | |
| tree | a48c5330ae9801a31dbf8b2a7dfcff30a4f21fc0 /src | |
| parent | 0dae37df97cff75350688d9540657c06dbe7795b (diff) | |
TreeViewDelegate: give tree items an accessible name
The TreeViewDelegate styles show the display role in a Label and leave
the text property empty, so a tree item had no accessible name. Now that
accessibility focus follows the current cell, VoiceOver on macOS
announced each item as just "text", because the bridge maps ListItem to
a static text element.
Name the delegate after the display role and ignore its Label, so an
item is read neither as empty text nor twice. This covers the Basic,
Fusion, iOS and Material styles, and the native style that the macOS
style uses.
This patch and its commit message were developed together with Claude
Change-Id: Ie7136e943e0eec9a8954a06750aaf36ea383bfa3
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src')
5 files changed, 30 insertions, 0 deletions
diff --git a/src/quickcontrols/basic/TreeViewDelegate.qml b/src/quickcontrols/basic/TreeViewDelegate.qml index b73f8c0ff4..4497c12da3 100644 --- a/src/quickcontrols/basic/TreeViewDelegate.qml +++ b/src/quickcontrols/basic/TreeViewDelegate.qml @@ -27,6 +27,11 @@ T.TreeViewDelegate { required property int row required property var model + + // The content item shows the same text, and stays out of the accessibility + // tree, so that the item is not read twice. + Accessible.name: control.model.display ?? "" + readonly property real __contentIndent: !isTreeNode ? 0 : (depth * indentation) + (indicator ? indicator.width + spacing : 0) indicator: Item { @@ -59,6 +64,7 @@ T.TreeViewDelegate { } contentItem: Label { + Accessible.ignored: true clip: false text: control.model.display elide: Text.ElideRight diff --git a/src/quickcontrols/fusion/TreeViewDelegate.qml b/src/quickcontrols/fusion/TreeViewDelegate.qml index 233be3b37d..6abb1d3b49 100644 --- a/src/quickcontrols/fusion/TreeViewDelegate.qml +++ b/src/quickcontrols/fusion/TreeViewDelegate.qml @@ -28,6 +28,11 @@ T.TreeViewDelegate { required property int row required property var model + + // The content item shows the same text, and stays out of the accessibility + // tree, so that the item is not read twice. + Accessible.name: control.model.display ?? "" + readonly property real __contentIndent: !isTreeNode ? 0 : (depth * indentation) + (indicator ? indicator.width + spacing : 0) indicator: Item { @@ -57,6 +62,7 @@ T.TreeViewDelegate { } contentItem: Label { + Accessible.ignored: true text: control.model.display elide: Text.ElideRight visible: !control.editing diff --git a/src/quickcontrols/ios/TreeViewDelegate.qml b/src/quickcontrols/ios/TreeViewDelegate.qml index 7a65b68577..6a85c59585 100644 --- a/src/quickcontrols/ios/TreeViewDelegate.qml +++ b/src/quickcontrols/ios/TreeViewDelegate.qml @@ -28,6 +28,11 @@ T.TreeViewDelegate { required property int row required property var model + + // The content item shows the same text, and stays out of the accessibility + // tree, so that the item is not read twice. + Accessible.name: control.model.display ?? "" + readonly property real __contentIndent: !isTreeNode ? 0 : (depth * indentation) + (indicator ? indicator.width + spacing : 0) indicator: Item { @@ -71,6 +76,7 @@ T.TreeViewDelegate { } contentItem: Label { + Accessible.ignored: true clip: false text: control.model.display elide: Text.ElideRight diff --git a/src/quickcontrols/material/TreeViewDelegate.qml b/src/quickcontrols/material/TreeViewDelegate.qml index dc909e507a..e5227b29d1 100644 --- a/src/quickcontrols/material/TreeViewDelegate.qml +++ b/src/quickcontrols/material/TreeViewDelegate.qml @@ -28,6 +28,11 @@ T.TreeViewDelegate { required property int row required property var model + + // The content item shows the same text, and stays out of the accessibility + // tree, so that the item is not read twice. + Accessible.name: control.model.display ?? "" + readonly property real __contentIndent: !isTreeNode ? 0 : (depth * indentation) + (indicator ? indicator.width + spacing : 0) indicator: Item { @@ -64,6 +69,7 @@ T.TreeViewDelegate { } contentItem: Label { + Accessible.ignored: true text: control.model.display elide: Text.ElideRight visible: !control.editing diff --git a/src/quickcontrols/quicknativestyle/controls/DefaultTreeViewDelegate.qml b/src/quickcontrols/quicknativestyle/controls/DefaultTreeViewDelegate.qml index 172f2ac68f..be7cbce978 100644 --- a/src/quickcontrols/quicknativestyle/controls/DefaultTreeViewDelegate.qml +++ b/src/quickcontrols/quicknativestyle/controls/DefaultTreeViewDelegate.qml @@ -28,6 +28,11 @@ T.TreeViewDelegate { required property int row required property var model + + // The content item shows the same text, and stays out of the accessibility + // tree, so that the item is not read twice. + Accessible.name: control.model.display ?? "" + readonly property real __contentIndent: !isTreeNode ? 0 : (depth * indentation) + (indicator ? indicator.width + spacing : 0) readonly property bool __notCustomizable: true @@ -58,6 +63,7 @@ T.TreeViewDelegate { } contentItem: Label { + Accessible.ignored: true clip: false text: control.model.display elide: Text.ElideRight |
