Setting accessibility label relation for widget
-
I am creating an app using PySide6 and I need to set the accessible label for a QComboBox, where the labelling text is on another QLabel in the UI. Reading the docs I find QAccessibleInterface has a relations method which can return any label or labelled relations for the widget, but I do not see how it should be set. A lot of the QT accessibility documentation seems to be discussing how to implement accessibility for custom widgets rather than just using standard QT widgets and setting a single relation and leaving the rest as implemented as standard. Please could someone explain how I can set the label relation between a QLabel and QComboBox? Thanks in advance for any help on this.
-
I am creating an app using PySide6 and I need to set the accessible label for a QComboBox, where the labelling text is on another QLabel in the UI. Reading the docs I find QAccessibleInterface has a relations method which can return any label or labelled relations for the widget, but I do not see how it should be set. A lot of the QT accessibility documentation seems to be discussing how to implement accessibility for custom widgets rather than just using standard QT widgets and setting a single relation and leaving the rest as implemented as standard. Please could someone explain how I can set the label relation between a QLabel and QComboBox? Thanks in advance for any help on this.
I have found the answer, or at least what I think is the answer. Providing it here in case anyone else ever has this problem, I don't think it was very obviousm It seems to be to use QLabel.setBuddy(arg) on the label object passing it the widget to be labelled. Making this call gets NVDA to correctly identify the label for the widget.
-