本页内容

QAccessibleEvent Class

QAccessibleEvent 类是辅助功能通知的基类。更多内容...

头文件: #include <QAccessibleEvent>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
被继承于:

QAccessibleAnnouncementEvent、QAccessibleStateChangeEvent 、QAccessibleTableModelChangeEvent 、QAccessibleTextCursorEvent 以及QAccessibleValueChangeEvent

公共函数

QAccessibleEvent(QAccessibleInterface *interface, QAccessible::Event type)
QAccessibleEvent(QObject *object, QAccessible::Event type)
virtual ~QAccessibleEvent()
virtual QAccessibleInterface *accessibleInterface() const
int child() const
QObject *object() const
void setChild(int child)
QAccessible::Event type() const

详细说明

此类与QAccessible::updateAccessibility() 配合使用。

事件类型是QAccessible::Event 的值之一。还有许多子类,应用于提供有关该事件的更多详细信息。

例如,在重新实现QWidget::setFocus 时,若要通知焦点变化,可按以下方式使用该事件:

void MyWidget::setFocus(Qt::FocusReason reason)
{
    // handle custom focus setting...
    QAccessibleEvent event(f, QAccessible::Focus);
    QAccessible::updateAccessibility(&event);
}

为了支持进程内的屏幕阅读器,所有事件都必须在变化发生之后才发送。

成员函数文档

QAccessibleEvent::QAccessibleEvent(QAccessibleInterface *interface, QAccessible::Event type)

构建一个 QAccessibleEvent 对象,用于通知interface 已发生变化。事件type 描述了具体发生了哪些变化。若您已拥有QAccessibleInterface 或不存在QObject ,请使用此函数;否则,请考虑使用接受QObject 参数的重载版本,因为该版本的执行成本可能更低。

QAccessibleEvent::QAccessibleEvent(QObject *object, QAccessible::Event type)

创建一个 QAccessibleEvent 对象,用于通知object 已发生变化。事件type 描述了发生了哪些变化。

[virtual noexcept] QAccessibleEvent::~QAccessibleEvent()

销毁该事件。

[virtual] QAccessibleInterface *QAccessibleEvent::accessibleInterface() const

返回与该事件关联的QAccessibleInterface 。

int QAccessibleEvent::child() const

返回子节点索引。

另请参阅 setChild()。

QObject *QAccessibleEvent::object() const

返回事件对象。

void QAccessibleEvent::setChild(int child)

将子索引设置为child 。

另请参阅 child()。

QAccessible::Event QAccessibleEvent::type() const

返回事件类型。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.