Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-137157

[macOS] QAccessibleInterface::window() is never called; accessibility tools cannot see the top-level window that holds a widget/Item

    XMLWordPrintable

Details

    • macOS

    Description

      TEST 1
      Code
      Qt Widgets version:

      #include <QtWidgets>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          QTextEdit te;
          te.setWindowTitle("Qt Widgets Window");
          te.show();
      
          return a.exec();
      }
      

       

      Qt Quick version:

      import QtQuick.Controls.Basic
      
      ApplicationWindow {
          width: 400
          height: 300
          visible: true
          title: "Qt Quick Window"
      
          TextArea { anchors.fill: parent }
      }
      

       

      Steps to reproduce

      Use Xcode's Accessibility Inspector to examine...

      1. ...the text input area of one of the Qt applications above
      2. ...the text input area of one of the native macOS TextEdit app

       

      Outcomes

      • (Step #1) Qt's "Text View" automation type has "None" as the value for its "Window" property (Not expected)
      • (Step #2) The macOS TextEdit's "Text View" automation type has a valid value for its "Window" property (Expected)

       

      TEST 2
      Code

      #include <QApplication>
      #include <QMainWindow>
      #include <QTextEdit>
      #include <QAccessibleWidget>
      
      class MyAccessibleWidget : public QAccessibleWidget
      {
      public:
          explicit MyAccessibleWidget(QWidget *w, const QString &name = "MyWidget")
              : QAccessibleWidget(w, QAccessible::EditableText, name)
          {}
      
          QString text(QAccessible::Text) const override
          {
              qDebug("MyAccessibleWidget::text() called");
              return QStringLiteral("Am I accessible?");
          }
      
          QWindow *window() const override
          {
              qDebug("MyAccessibleWidget::window() called");
              return QAccessibleWidget::window();
          }
      };
      
      static QAccessibleInterface *myFactoryFunction(const QString &, QObject *object)
      {
          auto te = qobject_cast<QTextEdit*>(object);
          return te ? new MyAccessibleWidget(te) : nullptr;
      }
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
          QAccessible::installFactory(&myFactoryFunction);
      
          QMainWindow mw;
          mw.setCentralWidget(new QTextEdit(&mw));
          mw.show();
      
          return app.exec();
      }
      

       

      Steps to reproduce

      1. Build and run the code above for both Windows and macOS
      2. Use the platform's accessibility checker to examine the QTextEdit of the example, while monitoring the qDebug output

       

      Outcomes

      • (Windows) The console output shows that both MyAccessibleWidget::text() and MyAccessibleWidget::window() are called many times (Expected)
      • (macOS) The console output shows that only MyAccessibleWidget::text() is called; MyAccessibleWidget::window() is never called (Not expected)

      Attachments

        1. macos-axinspector-qt.png
          202 kB
          Sze Howe Koh
        2. macos-axinspector-textedit.png
          168 kB
          Sze Howe Koh
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            skoh-qt Sze Howe Koh
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes