~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qt4-accessibility.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/doc/src/qt4-accessibility.qdoc -->
 
6
<head>
 
7
    <title>Qt 4.0: Cross-Platform Accessibility Support in Qt 4</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
    <link rel="prev" href="qt4-designer.html" />
 
15
    <link rel="contents" href="qt4-intro.html" />
 
16
    <link rel="next" href="qt4-sql.html" />
 
17
</head>
 
18
<body>
 
19
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
20
<tr>
 
21
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
22
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
23
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><p>
 
24
[Previous: <a href="qt4-designer.html">The New Qt Designer</a>]
 
25
[<a href="qt4-intro.html">Home</a>]
 
26
[Next: <a href="qt4-sql.html">The Qt 4 Database GUI Layer</a>]
 
27
</p>
 
28
<h1 align="center">Cross-Platform Accessibility Support in Qt 4</h1>
 
29
<p>Qt 4 allows developers to write cross-platform applications that are usable by visually impaired users as well as by users with other disabilities. Qt accessibility will make applications accessible to more users and opens the governmental market, where accessibility is often a requirement.</p>
 
30
<a name="general-overview"></a>
 
31
<h2>General Overview</h2>
 
32
<p>Qt 3 already supports Microsoft Active Accessibility (MSAA) and Mac OS X Accessibility. Qt 4 closes the gap in Trolltech's accessibility offering by introducing support for AT-SPI on Unix/<a href="winsystem.html#x11">X11</a> systems.</p>
 
33
<p>The accessibility classes themselves have been extended in various ways since Qt 3. We added new functions and new enum values, and revised the API to make it more consistent with the rest of Qt. We also added two properties to <a href="qwidget.html">QWidget</a>, <a href="qwidget.html#accessibleName-prop">accessibleName</a> and <a href="qwidget.html#accessibleDescription-prop">accessibleDescription</a>, that can be set in <i>Qt Designer</i> to provide basic help texts without having to write any code.</p>
 
34
<p>Qt's accessibility architecture is as follows. Qt offers one generic interface, <a href="qaccessibleinterface.html">QAccessibleInterface</a>, that can be used to wrap all widgets and objects (e.g., <a href="qpushbutton.html">QPushButton</a>). This single interface provides all the metadata necessary for the assistive technologies. Qt provides implementations of this interface for its built-in widgets as plugins.</p>
 
35
<p>When you develop custom widgets, you can create custom subclasses of <a href="qaccessibleinterface.html">QAccessibleInterface</a> and distribute them as plugins (using <a href="qaccessibleplugin.html">QAccessiblePlugin</a>) or compile them into the application. Likewise, Qt's predefined accessibility support can be built as plugin (the default) or directly into the Qt library. The main advantage of using plugins is that the accessibility classes are only loaded into memory if they are actually used; they don't slow down the common case where no assistive technology is being used.</p>
 
36
<p>In addition to <a href="qaccessibleinterface.html">QAccessibleInterface</a>, Qt includes two convenience classes, <a href="qaccessibleobject.html">QAccessibleObject</a> and <a href="qaccessiblewidget.html">QAccessibleWidget</a>, that provide the lowest common denominator of metadata (e.g., widget geometry, window title, basic help text). You can use them as base classes when wrapping your custom <a href="qobject.html">QObject</a> or <a href="qwidget.html">QWidget</a> subclasses.</p>
 
37
<p>Another new feature in Qt 4 is that Qt can now support other backends in addition to the predefined ones. This is done by subclassing <a href="qaccessiblebridge.html">QAccessibleBridge</a>.</p>
 
38
<a name="example-code"></a>
 
39
<h2>Example Code</h2>
 
40
<p>The first example illustrates how to provide accessibility information for a custom widget. We can use <a href="qaccessiblewidget.html">QAccessibleWidget</a> as a base class and reimplement various functions:</p>
 
41
<pre>&nbsp;   class MyWidgetInterface : public QAccessibleWidget
 
42
    {
 
43
    public:
 
44
        MyWidgetInterface(QWidget *widget, Role role);
 
45
 
 
46
        QString text(Text text, int child) const;
 
47
        State state(int child) const;
 
48
        QString actionText(int action, Text text, int child) const;
 
49
        bool doAction(int action, int child, const QVariantList &amp;params);
 
50
        ...
 
51
    };</pre>
 
52
<p>Here's how we would implement the <a href="qaccessibleinterface.html#doAction">doAction()</a> function to call a function named click() on the wrapped MyWidget object when the user invokes the object's default action or &quot;presses&quot; it.</p>
 
53
<pre>&nbsp;   bool MyWidgetInterface::doAction(int action, int child,
 
54
                                     const QVariantList &amp;params)
 
55
    {
 
56
        if (child || !widget()-&gt;isEnabled())
 
57
            return false;
 
58
 
 
59
        switch (action) {
 
60
        case DefaultAction:
 
61
        case Press:
 
62
            {
 
63
                MyWidget *widget = qobject_cast&lt;MyWidget *&gt;(object());
 
64
                if (widget)
 
65
                    widget-&gt;click();
 
66
            }
 
67
            return true;
 
68
        }
 
69
        return QAccessibleWidget::doAction(action, child, params);
 
70
    }</pre>
 
71
<p>To export the widget interface as a plugin, we must subclass QAccessibleFactory:</p>
 
72
<pre>&nbsp;   QStringList MyFactory::keys() const
 
73
    {
 
74
        return QStringList() &lt;&lt; &quot;MyWidget&quot; &lt;&lt; &quot;MyOtherWidget&quot;;
 
75
    }
 
76
 
 
77
    QAccessibleInterface *MyFactory::create(const QString &amp;className,
 
78
                                            QObject *object)
 
79
    {
 
80
        if (classname == &quot;MyWidget&quot;)
 
81
            return new MyWidgetInterface(object);
 
82
        if (classname == &quot;MyOtherWidget&quot;)
 
83
            return new MyOtherWidgetInterface(object);
 
84
        return 0;
 
85
    }
 
86
 
 
87
    Q_EXPORT_PLUGIN(MyFactory)</pre>
 
88
<p>
 
89
[Previous: <a href="qt4-designer.html">The New Qt Designer</a>]
 
90
[<a href="qt4-intro.html">Home</a>]
 
91
[Next: <a href="qt4-sql.html">The Qt 4 Database GUI Layer</a>]
 
92
</p>
 
93
<p /><address><hr /><div align="center">
 
94
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
95
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
96
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
97
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
98
</tr></table></div></address></body>
 
99
</html>