Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Create accessible applications with Qt



  • Hi,

    in a tutorial video I saw that Qt surface components
    have the properties "AccessibleName" and "AccessibleDescription".
    This suggests that Qt applications are screen readable
    can be developed. In the programming languages ​​are called Java and C #
    the properties the same.
    I am developing Python on Windows 10

    Question:
    Is there a guide on how to make a Python Qt application suitable for screen readers?



  • I don't know about this but maybe you can refer to the doc:
    https://doc.qt.io/qt-5/accessible-qwidget.html



  • Thank you! But unfortunately I couldn't find anything about screen readers in the examples.



  • Ah, also this doc: https://doc.qt.io/qt-5/accessible.html

    Applications do not usually communicate directly with the assistive tools, but through a platform specific API. Generally the communication with the ATs works though an IPC mechanism. Semantic information about user interface elements, such as buttons and scroll bars, is exposed to the assistive technologies. Qt supports UI Automation on Windows, macOS Accessibility on macOS, and AT-SPI via DBus on Unix/X11. The platform specific technologies are abstracted by Qt, so that applications do not need any platform specific changes to work with the different native APIs. Qt tries to make adding accessibility support to your application as easy as possible, only a few changes from your side may be required to allow even more users to enjoy it.

    From that I can get that Qt does not provide screen readers itself, but it supports platform specific assistive technologies.
    So the screen reader of the platform should be turned on first. Then you can try the example.
    Sorry, this is as far as I can understand...



  • Okay. Maybe you can give an example. Windows 10.

    I have a QPushButton:

    button = QPushButton ('TestSchalter', window)
    button.move (50, 50)
    

    I would like to add a text to this QPushButton, which is read out by the screen reader http://nvda.bhvd.de/.
    What do I have to do?



  • According to the doc I posted above, Qt only supports UI Automation on Windows.
    And as I said, I don't know anything about accessibility, so I can't help you further.



  • okay, last try:
    I found the following directory on my hard drive:

    C: \ PythonQt \ Examples \ Qt-5.14.2 \ quick \ quick-accessibility

    Has anyone else besides me and can tell me what it's about?



  • Hi,

    the reason I'm mistaken is that there is a bug on Windows. I still have to set whether the bug with Qt or the screen reader is NVDA.

    The following code works under Ubuntu 20.04 with the screen reader Orca, which can be found in Ubuntu in the access aids:

    #!/usr/bin/env python3
    import sys
    from PyQt5 import QtCore, QtWidgets
    from PyQt5.QtWidgets import *
    from PyQt5.QtCore import QSize
    
    class MyWindow(QMainWindow):
        def __init__(self):
            # Konstruktor von QMainWindow aufrufen
            super().__init__()
    
            # Fenstergröße und Titel einstellen
            self.setMinimumSize(QSize(300, 100))
            self.setWindowTitle('Barrierefreiheit mit Qt')
    
            def sag_HalloWindows():
                print("Hallo Windows!")
    
            def sag_HalloUbuntu():
                print("Hallo Ubuntu!")
    
            vButtonWindows = QPushButton("Hallo Windows",self)
            vButtonWindows.setGeometry(0,0,80,30)
            vButtonWindows.setAccessibleDescription("Es wird ein Hallo Windows auf der Console ausgeben")
            vButtonWindows.clicked.connect(sag_HalloWindows)
            vButtonWindows.show()
    
            vButtonUbuntu = QPushButton("Hallo Ubuntu!",self)
            vButtonUbuntu.setGeometry(0, 50,80,30)
            vButtonUbuntu.setAccessibleDescription("Es wird ein Hallo Ubuntu auf der Console ausgeben")
            vButtonUbuntu.clicked.connect(sag_HalloUbuntu)
            vButtonUbuntu.show()
    
    app = QtWidgets.QApplication([])
    win = MyWindow()
    win.show()
    app.exec_()
    

    Folgender Code funktioniert unter Windows 10 mit dem kostenlosen Screenreader http://nvda.bhvd.de/

    #!/usr/bin/env python3
    import sys
    from PyQt5 import QtCore, QtWidgets
    from PyQt5.QtWidgets import *
    from PyQt5.QtCore import QSize
    
    class MyWindow(QMainWindow):
        def __init__(self):
            # Konstruktor von QMainWindow aufrufen
            super().__init__()
    
            # Fenstergröße und Titel einstellen
            self.setMinimumSize(QSize(300, 100))
            self.setWindowTitle('Barrierefreiheit mit Qt')
    
            def sag_HalloWindows():
                print("Hallo Windows!")
    
            def sag_HalloUbuntu():
                print("Hallo Ubuntu!")
    
            vButtonWindows = QPushButton("Hallo Windows",self)
            vButtonWindows.setGeometry(0,0,80,30)
            vButtonWindows.setAccessibleName("Es wird ein Hallo Windows auf der Console ausgeben")
            vButtonWindows.clicked.connect(sag_HalloWindows)
            vButtonWindows.show()
    
            vButtonUbuntu = QPushButton("Hallo Ubuntu!",self)
            vButtonUbuntu.setGeometry(0, 50,80,30)
            vButtonUbuntu.setAccessibleName("Es wird ein Hallo Ubuntu auf der Console ausgeben")
            vButtonUbuntu.clicked.connect(sag_HalloUbuntu)
            vButtonUbuntu.show()
    
    app = QtWidgets.QApplication([])
    win = MyWindow()
    win.show()
    app.exec_()
    

    Does anyone have any other ideas how I can find out what goes wrong with Windows 10?



  • Now I know how to do it. I tested it on Windows, Ubuntu and MacOS:
    self.comboschriftart.setAccessibleName("Auswahlliste um Schriftart festzulegen")
    self.comboschriftgroesse.setAccessibleName("Auswahlliste um Schriftartgrad festzulegen")
    The screenreaders Jaws, NVDA, Orca and Voice Over reads the property "AccessibleName" .They don't read the property "AccessibleDescription".


Log in to reply