1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the documentation of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | /*!
|
---|
43 | \page qt4-accessibility.html
|
---|
44 | \title Cross-Platform Accessibility Support in Qt 4
|
---|
45 | \ingroup accessibility
|
---|
46 |
|
---|
47 | \contentspage {What's New in Qt 4}{Home}
|
---|
48 | \previouspage The New Qt Designer
|
---|
49 | \nextpage The Qt 4 Database GUI Layer
|
---|
50 |
|
---|
51 | Qt 4 allows developers to write cross-platform applications that
|
---|
52 | are usable by visually impaired users as well as by users with
|
---|
53 | other disabilities. Qt accessibility will make applications
|
---|
54 | accessible to more users and opens the governmental market, where
|
---|
55 | accessibility is often a requirement.
|
---|
56 |
|
---|
57 | \section1 General Overview
|
---|
58 |
|
---|
59 | The accessibility classes have been extended in
|
---|
60 | various ways since Qt 3. We added new functions and new enum
|
---|
61 | values, and revised the API to make it more consistent with the
|
---|
62 | rest of Qt. We also added two properties to QWidget,
|
---|
63 | \l{QWidget::accessibleName}{accessibleName} and
|
---|
64 | \l{QWidget::accessibleDescription}{accessibleDescription}, that
|
---|
65 | can be set in \e{Qt Designer} to provide basic help texts without
|
---|
66 | having to write any code.
|
---|
67 |
|
---|
68 | Qt's accessibility architecture is as follows. Qt offers one
|
---|
69 | generic interface, QAccessibleInterface, that can be used to
|
---|
70 | wrap all widgets and objects (e.g., QPushButton). This single
|
---|
71 | interface provides all the metadata necessary for the assistive
|
---|
72 | technologies. Qt provides implementations of this interface for
|
---|
73 | its built-in widgets as plugins.
|
---|
74 |
|
---|
75 | A more detailed overview of the accessibility support in Qt can
|
---|
76 | be found on the \l Accessibility page.
|
---|
77 |
|
---|
78 | \section1 Enabling Accessibility Support
|
---|
79 |
|
---|
80 | By default, Qt applications are run with accessibility support
|
---|
81 | enabled on Windows and Mac OS X. On Unix/X11 platforms, applications
|
---|
82 | must be launched in an environment with the \c QT_ACCESSIBILITY
|
---|
83 | variable set to 1. For example, this is set in the following way with
|
---|
84 | the bash shell:
|
---|
85 |
|
---|
86 | \snippet doc/src/snippets/code/doc_src_qt4-accessibility.qdoc environment
|
---|
87 |
|
---|
88 | Accessibility features are built into Qt by default when the libraries
|
---|
89 | are configured and built.
|
---|
90 |
|
---|
91 | \section1 Creating New Accessible Interfaces
|
---|
92 |
|
---|
93 | When you develop custom widgets, you can create custom subclasses
|
---|
94 | of QAccessibleInterface and distribute them as plugins (using
|
---|
95 | QAccessiblePlugin) or compile them into the application.
|
---|
96 | Likewise, Qt's predefined accessibility support can be built as
|
---|
97 | plugin (the default) or directly into the Qt library. The main
|
---|
98 | advantage of using plugins is that the accessibility classes are
|
---|
99 | only loaded into memory if they are actually used; they don't
|
---|
100 | slow down the common case where no assistive technology is being
|
---|
101 | used.
|
---|
102 |
|
---|
103 | In addition to QAccessibleInterface, Qt includes two convenience
|
---|
104 | classes, QAccessibleObject and QAccessibleWidget, that
|
---|
105 | provide the lowest common denominator of metadata (e.g., widget
|
---|
106 | geometry, window title, basic help text). You can use them as
|
---|
107 | base classes when wrapping your custom QObject or QWidget
|
---|
108 | subclasses.
|
---|
109 |
|
---|
110 | Another new feature in Qt 4 is that Qt can now support other
|
---|
111 | backends in addition to the predefined ones. This is done by
|
---|
112 | subclassing QAccessibleBridge.
|
---|
113 |
|
---|
114 | \omit
|
---|
115 | \section1 Software Layering
|
---|
116 |
|
---|
117 | Qt Application
|
---|
118 | | links to
|
---|
119 | Qt Accessibility Module
|
---|
120 | | Plugin (in-process)
|
---|
121 | Qt ATK Bridge
|
---|
122 | | links to
|
---|
123 | ATK
|
---|
124 | | Plugin (in-process)
|
---|
125 | at-spi
|
---|
126 | | CORBA
|
---|
127 | assistive technologies
|
---|
128 |
|
---|
129 | Windows:
|
---|
130 |
|
---|
131 | Qt Application
|
---|
132 | | links to
|
---|
133 | Qt Accessibility Module
|
---|
134 | | COM (?)
|
---|
135 | MSAA
|
---|
136 | | ?
|
---|
137 | assistive technologies
|
---|
138 |
|
---|
139 | Mac:
|
---|
140 |
|
---|
141 | ?
|
---|
142 | \endomit
|
---|
143 |
|
---|
144 | \section1 Example Code
|
---|
145 |
|
---|
146 | The first example illustrates how to provide accessibility
|
---|
147 | information for a custom widget. We can use QAccessibleWidget as
|
---|
148 | a base class and reimplement various functions:
|
---|
149 |
|
---|
150 | \snippet doc/src/snippets/code/doc_src_qt4-accessibility.qdoc 0
|
---|
151 |
|
---|
152 | Here's how we would implement the
|
---|
153 | \l{QAccessibleInterface::doAction()}{doAction()} function to call
|
---|
154 | a function named click() on the wrapped MyWidget object when the
|
---|
155 | user invokes the object's default action or "presses" it.
|
---|
156 |
|
---|
157 | \snippet doc/src/snippets/code/doc_src_qt4-accessibility.qdoc 1
|
---|
158 |
|
---|
159 | To export the widget interface as a plugin, we must subclass
|
---|
160 | QAccessibleFactory:
|
---|
161 |
|
---|
162 | \snippet doc/src/snippets/code/doc_src_qt4-accessibility.qdoc 2
|
---|
163 | */
|
---|