KDE Accessibility • Inform • Home

Qt Accessibility Architecture

This description of the Qt Accessibility Architecture was written by Gunnar Schmi Dt as part of our development efforts for interoperable accessibility solutions. Thanks to José Pablo Ezequiel Fernández for earlier work on the topic.

Introduction

The Qt Accessibility Architecture was added to Qt for providing support for the Microsoft Active Accessibility (MSAA) technology on Windows. MSAA can be described as a part of the operating system that collects accessibility relevant information from MSAA aware applications and offers these information to assistive technologies.

Unfortunately MSAA was not designed to be the only source of information that is used by assistive technologies. It rather complements existing technologies for determining what is on the screen (such as the Microsoft Screen Access Model (MSAM)).

In order to design a technology similar to MSAA for Unix systems you have to start from scratch as there are no technologies as MSAM. As a result of that it will be neccessary to extend the Qt Accessibility Architecture to fit the extended requirements.

An Overview of the Architecture

The basic idea for the current design of the Qt Accessibility Architecture is to provide an accessibility object for all widgets within the application. However, only the base classes for these objects are part of the Qt library, the actual implementation of the accessibility information for the widgets is hidden in a plug-in.

For widgets that are implemented outside of Qt (i.e., KDE widgets or application widgets) it is possible to install additional plug-ins.

A More Detailed View on the Architecture

Diagram for Qt Accessibility. Description follows

The three classes of the Qt Accessibility Architecture that are part of the Qt library are QAccessible, QAccessibleInterface, and QAccessibleObject. QAccessible consists of two static methods and a number of enumerations. QAccessibleInterface is the most important class outside of the plug-in. It is derived from QAccessible and contains pure virtual methods for enquiring all available information. The QAccessibleObject class is inherited from QAccessibleInterface and implements part of the functionality. For this purpose it also has a reference to the QObject it represents.

The plug-ins contain implementations for QAccessibleInterface for all Qt widgets. The base class for these implementations is QAccessibleWidget, from which all other classes of the plug-in are derived. Some of these derived classes have a reference to the corresponding Qt widget (as for example QAccessibleButton), others use the reference that is part of QAccessibleWidget (as for example QAccessibleText). QAccessibleWidget is inherited from QAccessibleObject.

Unfortunately not all GUI elements within Qt are widgets. For example the entries within a QTable or a QListView are simple C++ classes. For these elements no QAccessibleInterface instance is created. Instead you will have to use the QAccessibleInstance of the parent widget for handling these elements.

In order to inform the Qt Accessibility Architecture architecture about changes in the accessibility information the widgets have to call a static method within the QAccessible class.

Details About the Core Classes

The QAccessible Class

The QAccessible class simply contains a three static methods and a number of enumerations:

  • The method static bool isActive() returns true if accessibility information have been requested by an AT client.

  • The method static QRESULT queryAccessibleInterface (QObject *object, QAccessibleInterface **iface) can be used to create a QAccessibleInterface instance for a given QObject. In order to do this, the method takes the class name of the object and checks which plug-in can handle the object. If no such plug-in is found, the method continues with the parent class and so on.

    Please note that not all GUI elemants within Qt are inherited from QObject. For example the entries within a QTable or a QListView are simple C++ classes, so you cannot use this method on these. Instead you need to use call this method for their parent widget.

  • The method static void updateAccessibility (QObject *object, int control, Event reason) needs to be called whenever the accessibility information changes.

  • The enumeration Event describes possible reasons for changes to the accessibility information.

  • The enumerations State and Role describe the different states and roles a GUI element can have.

  • The enumeration NavDirection is used for navigating between child elements of an object.

  • The enumeration Text defines different types of textual information (as for example the name, description and value of an object).

The QAccessibleInterface Class

The QAccessibleInterface class is designed to be the only contract between the accessibility implementation of the widgets and the bridge to the accessibility infrastructure within the system. It provides methods for accessing many relevant properties:

  • The method pure virtual bool isValid() const returns true if the data returned by the QAccessibleInterface class is valid (all returned pointers are valid etc.). It is implemented for all objects.

  • The methods pure virtual int childCount() const, pure virtual QRESULT queryChild (int control, QAccessibleInterface **iface) const, and pure virtual QRESULT queryParent (QAccessibleInterface **iface) const can be used to enquire QAccessibilityInterface objects for the children and for the parent. They are implemented for all objects.

  • The methods pure virtual Role role (int control) const and pure virtual state (int control) const can be used to enquire the role and the state of the object or one of its children. They are implemented for all objects.

  • The method pure virtual int navigate (NavDirection direction, int startControl) const can be used to navigate through the children of the object. It is implemented for all objects.

  • The method pure virtual bool setFocus (int control) const can be used to set the focus.

  • The methods pure virtual int controlAt (int x, int y) const, and pure virtual QRect rect (int control) const can be used to enquire screen coordinates for the objects. They are implemented for all visual objects.

  • The methods pure virtual QMemArray<int> selection () const, pure virtual bool setSelected (int control, bool on, bool extend) and pure virtual clearSelection () can be used to handle the selection of child objects.

  • The methods pure virtual QString text (Text t, int control) const and pure virtual setText (Text t, int control, const QString &text) can be used to enquire or set various textual informations of the object or one of its children.

  • The method virtual bool doDefaultAction (int control) can be used to trigger the default action of the object or one of its children.

The QAccessibleObject Class

This class is mainly provided for convenience. It is recommended that all subclasses of QAccessibleInterface use this class as their base class. It implements part of the QAccessibleInterface interface for QObjects.

Further Information

In the Qt Reference Documentation you can find details on the three classes QAccessible, QAccessibleInterface, and QAccessibleObject

Global navigation links