QWidget* button = new QPushButton("Click me"); QAccessibleInterface* qaiButton = QAccessible::queryAccessibleInterface(button); if(qaiButton->isValid()) { qDebug() << "QAccessibleInterface of QPushButton is valid!"; }
QWidget* label = new QLabel("Hello World!"); QAccessibleInterface* qaiLabel = QAccessible::queryAccessibleInterface(label); if(!qaiLabel->isValid()) { qDebug() << "QAccessibleInterface of QLabel is not valid!"; }In this example, a QLabel widget is created and a QAccessibleInterface instance is obtained using the QAccessible::queryAccessibleInterface() function. The isValid() function is used to check whether this QAccessibleInterface is valid or not. The QAccessibleInterface class is part of the Qt Accessibility module.