1

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(){
    if(QAccessible::isActive()){
         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);
              QAccessible::updateAccessibility(ev); 

         }
    }
}

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?

user6106573
  • 193
  • 2
  • 11
  • I don't know QT, but knowing about WXWidgets, I would say that your widget may not have a corresponding accessible interface. It isn't necessary, and can even be detrimental to accessibility, if the widget is a standard WinAPI one. – QuentinC Mar 18 '22 at 18:24

1 Answers1

0

solution that seems to work:

if(QAccessible::isActive()){
    QWidget* focusedWidget = QApplication::focusWidget();
    if(focusedWidget != nullptr){
        auto *ev =  new QAccessibleValueChangeEvent(focusedWidget, "New Message");
        QAccessible::updateAccessibility(ev);
    }
}
user6106573
  • 193
  • 2
  • 11