#include#include #include int main(int argc, char **argv) { QApplication app(argc, argv); QLabel label("Hello, World!"); label.show(); QAccessible::setRootObject(&label); return app.exec(); }
#includeThis example creates a custom accessible object that inherits from QAccessibleWidget. The object returns a custom name for the widget that will be exposed to accessibility tools.#include class MyWidgetAccessible : public QAccessibleWidget { public: MyWidgetAccessible(QWidget *widget) : QAccessibleWidget(widget, QAccessible::ButtonRole) {} QString text(QAccessible::Text t) const override { if (t == QAccessible::Name) return "My Custom Widget"; return QAccessibleWidget::text(t); } }; int main(int argc, char **argv) { QApplication app(argc, argv); QWidget widget; widget.show(); auto acc = new MyWidgetAccessible(&widget); QAccessible::setRootObject(acc); return app.exec(); }