[SOLVED] Accessibility notification in Qt


I am trying to push notification to Jaws or NVDA when certain events occur.
These events can occur any time and any application widget can have the focus. They are not linked to user actions but to the controller events.
This is my try:

void announceNewMessageIfNeeded(){
         QWidget* focusWidget = QApplication::focusWidget();
         if(focusWidget != nullptr){
              auto* accessibleInterface = QAccessible::queryAccessibleInterface(focusWidget);
              accessibleInterface->setText(QAccessible::Name, "New Message");
              auto *ev = new QAccessibleEvent(accessibleInterface, QAccessible::Alert);


I tried the above code with various little changes but I either do not have accesibility update or undesired access to nullpointers.
With debug logs, I know for sure that the focusWidget is correct (it points to the item having the currentFocus) and that announceNewMessageIfNeeded is called.
Any idea?


solution that seems to work:

    QWidget* focusedWidget = QApplication::focusWidget();
    if(focusedWidget != nullptr){
        auto *ev =  new QAccessibleValueChangeEvent(focusedWidget, "New Message");

Answered By – user6106573

Answer Checked By – Marie Seifert (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *