summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/code/doc_src_qt4-accessibility.qdoc
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/snippets/code/doc_src_qt4-accessibility.qdoc')
-rw-r--r--doc/src/snippets/code/doc_src_qt4-accessibility.qdoc59
1 files changed, 59 insertions, 0 deletions
diff --git a/doc/src/snippets/code/doc_src_qt4-accessibility.qdoc b/doc/src/snippets/code/doc_src_qt4-accessibility.qdoc
new file mode 100644
index 0000000..8bed0a9
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qt4-accessibility.qdoc
@@ -0,0 +1,59 @@
+//! [environment]
+export QT_ACCESSIBILITY=1
+//! [environment]
+
+//! [0]
+class MyWidgetInterface : public QAccessibleWidget
+{
+public:
+ MyWidgetInterface(QWidget *widget, Role role);
+
+ QString text(Text text, int child) const;
+ State state(int child) const;
+ QString actionText(int action, Text text, int child) const;
+ bool doAction(int action, int child, const QVariantList &params);
+ ...
+};
+//! [0]
+
+
+//! [1]
+bool MyWidgetInterface::doAction(int action, int child,
+ const QVariantList &params)
+{
+ if (child || !widget()->isEnabled())
+ return false;
+
+ switch (action) {
+ case DefaultAction:
+ case Press:
+ {
+ MyWidget *widget = qobject_cast<MyWidget *>(object());
+ if (widget)
+ widget->click();
+ }
+ return true;
+ }
+ return QAccessibleWidget::doAction(action, child, params);
+}
+//! [1]
+
+
+//! [2]
+QStringList MyFactory::keys() const
+{
+ return QStringList() << "MyWidget" << "MyOtherWidget";
+}
+
+QAccessibleInterface *MyFactory::create(const QString &className,
+ QObject *object)
+{
+ if (classname == "MyWidget")
+ return new MyWidgetInterface(object);
+ if (classname == "MyOtherWidget")
+ return new MyOtherWidgetInterface(object);
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(myfactory, MyFactory)
+//! [2]