QAccessible 类

The QAccessible class provides enums and static functions relating to accessibility. 更多...

头: #include <QAccessible>
继承者: QAccessibleInterface and QAccessiblePlugin

公共类型

enum 动作 { DefaultAction, Press, SetFocus, Increase, ..., LastStandardAction }
enum Event { AcceleratorChanged, ActionChanged, ActiveDescendantChanged, Alert, ..., VisibleDataChanged }
typedef InterfaceFactory
enum Method { ListSupportedMethods, SetCursorPosition, GetCursorPosition }
flags Relation
enum RelationFlag { Unrelated, Self, Ancestor, Child, ..., Controlled }
enum Role { AlertMessage, Animation, Application, Assistant, ..., Window }
flags State
enum StateFlag { Animated, Busy, Checked, Collapsed, ..., Unavailable }
enum Text { Name, Description, Value, Help, Accelerator, UserText }

静态公共成员

void installFactory (InterfaceFactory factory )
RootObjectHandler installRootObjectHandler (RootObjectHandler handler )
bool isActive ()
QAccessibleInterface * queryAccessibleInterface (QObject * object )
void removeFactory (InterfaceFactory factory )
void setRootObject (QObject * object )
void updateAccessibility (QObject * object , int child , Event reason )

详细描述

The QAccessible class provides enums and static functions relating to accessibility.

可访问应用程序可以由无法使用应用程序的人来使用,按约定方式。

此类中的函数被用于可访问应用程序 (也称 AT 服务器) 和可访问工具 (AT 客户机) (如屏幕阅读器和盲文显示) 之间的通信。客户端和服务器采有以下办法通信:

服务器和客户端之间通信的初始化是通过 setRootObject () function. Function pointers can be installed to replace or extend the default behavior of the static functions in QAccessible .

Qt supports Microsoft Active Accessibility (MSAA), Mac OS X Accessibility, and the Unix/X11 AT-SPI standard. Other backends can be supported using QAccessibleBridge .

除了 QAccessible 's static functions, Qt offers one generic interface, QAccessibleInterface ,可用于包裹所有 Widget 和对象 (如 QPushButton )。此单一接口为辅助技术,提供所有必要元数据。Qt 为内置 Widget 作为插件提供此接口的实现。

当开发自定义 Widget 时,可以创建自定义子类为 QAccessibleInterface 并将它们分发作为插件 (使用 QAccessiblePlugin ) 或将它们编译进应用程序。同样,Qt 的预定义可访问性支持可以构建作为插件 (默认),或直接构建进 Qt 库。使用插件的主要优点是可访问性类仅加载进内存,若它们被实际使用;它们不会减慢没有使用辅助技术的常见情况。

Qt 还包括 2 方便类: QAccessibleObject and QAccessibleWidget ,继承自 QAccessibleInterface 并提供最小元数据公分母 (如:Widget 几何图形、窗口标题、基本帮助文本)。可以把它们用作基类,当包裹自定义 QObject or QWidget 子类。

另请参阅 QAccessibleInterface .

成员类型文档编制

enum QAccessible:: 动作

This enum describes the possible types of action that can occur.

常量
QAccessible::DefaultAction 0
QAccessible::Press -1
QAccessible::SetFocus -2
QAccessible::Increase -3
QAccessible::Decrease -4
QAccessible::Accept -5
QAccessible::Cancel -6
QAccessible::Select -7
QAccessible::ClearSelection -8
QAccessible::RemoveSelection -9
QAccessible::ExtendSelection -10
QAccessible::AddToSelection -11
QAccessible::FirstStandardAction Press
QAccessible::LastStandardAction AddToSelection

enum QAccessible:: Event

此枚举类型定义可访问事件类型。

常量 描述
QAccessible::AcceleratorChanged 0x80C0 动作的键盘加速键已改变。
QAccessible::ActionChanged 0x0101 动作已改变。
QAccessible::ActiveDescendantChanged 0x0102
QAccessible::Alert 0x0002 系统警报 (如:消息来自 QMessageBox )
QAccessible::AttributeChanged 0x0103
QAccessible::ContextHelpEnd 0x000D 上下文帮助 ( QWhatsThis ) 对于已完成对象而言。
QAccessible::ContextHelpStart 0x000C 上下文帮助 ( QWhatsThis ) 对于已初启对象而言。
QAccessible::DefaultActionChanged 0x80B0 默认 QAccessible::Action for the accessible object has changed.
QAccessible::DescriptionChanged 0x800D 对象的 QAccessible::Description 改变。
QAccessible::DialogEnd 0x0011 对话框 ( QDialog ) 已被隐藏
QAccessible::DialogStart 0x0010 对话框 ( QDialog ) 已被设为可见。
QAccessible::DocumentContentChanged 0x0104 文本文档的内容已改变。
QAccessible::DocumentLoadComplete 0x0105 文档已加载。
QAccessible::DocumentLoadStopped 0x0106 文档加载已停止。
QAccessible::DocumentReload 0x0107 文档重载已初启。
QAccessible::DragDropEnd 0x000F 拖放操作即将完成。
QAccessible::DragDropStart 0x000E 拖放操作即将被初启。
QAccessible::Focus 0x8005 对象已获得键盘聚焦。
QAccessible::ForegroundChanged 0x0003 A window has been activated (i.e., a new window has gained focus on the desktop).
QAccessible::HelpChanged 0x80A0 The QAccessible::Help 对象的文本特性已改变。
QAccessible::HyperlinkEndIndexChanged 0x0108 超文本链接的显示文本的结束位置已改变。
QAccessible::HyperlinkNumberOfAnchorsChanged 0x0109 超文本链接中的锚点数已变化,或许因为显示文本已被拆分以提供多个链接。
QAccessible::HyperlinkSelectedLinkChanged 0x010A 选中的超文本链接的链接已改变。
QAccessible::HyperlinkStartIndexChanged 0x010D 超文本链接的显示文本的起始位置已改变。
QAccessible::HypertextChanged 0x010E 用于超文本链接的显示文本已改变。
QAccessible::HypertextLinkActivated 0x010B A hypertext link has been activated, perhaps by being clicked or via a key press.
QAccessible::HypertextLinkSelected 0x010C 超文本链接已被选中。
QAccessible::HypertextNLinksChanged 0x010F
QAccessible::LocationChanged 0x800B 对象在屏幕上的位置已改变。
QAccessible::MenuCommand 0x0018 菜单项被触发。
QAccessible::MenuEnd 0x0005 菜单已关闭 (Qt 对所有菜单使用 PopupMenuEnd)。
QAccessible::MenuStart 0x0004 菜单栏上的菜单已打开 (Qt 对所有菜单使用 PopupMenuStart)。
QAccessible::NameChanged 0x800C The QAccessible::Name 对象的特性已改变。
QAccessible::ObjectAttributeChanged 0x0110
QAccessible::ObjectCreated 0x8000 新对象被创建。
QAccessible::ObjectDestroyed 0x8001 对象被删除。
QAccessible::ObjectHide 0x8003 对象被隐藏;例如,采用 QWidget::hide ()。任何被隐藏的子级对象不会发送此事件。它不会被发送,当对象被其它对象遮挡时。
QAccessible::ObjectReorder 0x8004 布局或项视图已添加、移除或移动对象 (Qt 不使用此事件)。
QAccessible::ObjectShow 0x8002 对象被显示;例如,采用 QWidget::show ().
QAccessible::PageChanged 0x0111
QAccessible::ParentChanged 0x800F 对象的父级对象已改变。
QAccessible::PopupMenuEnd 0x0007 弹出菜单已关闭。
QAccessible::PopupMenuStart 0x0006 弹出菜单已打开。
QAccessible::ScrollingEnd 0x0013 滚动条卷动操作已结束 (鼠标已释放滑块手柄)。
QAccessible::ScrollingStart 0x0012 滚动条卷动操作即将开始;例如,这可能是由鼠标在滑块上按下而引起。
QAccessible::SectionChanged 0x0112
QAccessible::SelectionAdd 0x8007 项已被添加到项视图选定中。
QAccessible::SelectionRemove 0x8008 项已从项视图选定中被移除。
QAccessible::Selection 0x8006 在菜单或项视图中的选定已改变。
QAccessible::SelectionWithin 0x8009 项视图中的选定已有几处改变。
QAccessible::SoundPlayed 0x0001 声音已由对象播放
QAccessible::StateChanged 0x800A The QAccessible::State of an object has changed.
QAccessible::TableCaptionChanged 0x0113 表格标题已改变。
QAccessible::TableColumnDescriptionChanged 0x0114 在列标题中通常找到的表格列的描述已改变。
QAccessible::TableColumnHeaderChanged 0x0115 表格列标题已改变。
QAccessible::TableModelChanged 0x0116 The model providing data for a table has been changed.
QAccessible::TableRowDescriptionChanged 0x0117 在行标题中通常找到的表格行的描述已改变。
QAccessible::TableRowHeaderChanged 0x0118 表格行标题已改变。
QAccessible::TableSummaryChanged 0x0119 表格摘要已改变。
QAccessible::TextAttributeChanged 0x011A
QAccessible::TextCaretMoved 0x011B The caret has moved in an editable widget. The caret represents the cursor position in an editable widget with the input focus.
QAccessible::TextColumnChanged 0x011D 文本列已改变。
QAccessible::TextInserted 0x011E Text has been inserted into an editable widget.
QAccessible::TextRemoved 0x011F Text has been removed from an editable widget.
QAccessible::TextSelectionChanged 0x0121 The selected text has changed in an editable widget.
QAccessible::TextUpdated 0x0120 The text has been update in an editable widget.
QAccessible::ValueChanged 0x800E The QAccessible::Value of an object has changed.
QAccessible::VisibleDataChanged 0x0122

此枚举的值被定义为相同值,如那些定义于 IAccessible2 and MSAA 规范。

typedef QAccessible:: InterfaceFactory

这是采用以下签名的函数指针的 typedef:

typedef QAccessibleInterface* myFactoryFunction(const QString &key, QObject *);
					

函数接收 QString QObject 指针,其中 QString 是标识接口的关键。 QObject 被用来传递给 QAccessibleInterface 以便可以保持对它的引用。

若键和 QObject 没有相应 QAccessibleInterface , a null-pointer will be returned.

已安装工厂的调用是通过 queryAccessibilityInterface(),直到一个提供接口为止。

enum QAccessible:: 方法

This enum describes the possible types of methods that can be invoked on an accessible object.

常量
QAccessible::ListSupportedMethods 0
QAccessible::SetCursorPosition 1
QAccessible::GetCursorPosition 2

另请参阅 QAccessibleInterface::invokeMethod ().

enum QAccessible:: RelationFlag
flags QAccessible:: Relation

此枚举类型定义可以组合以指示 2 可访问对象间关系的位标志。

常量 描述
QAccessible::Unrelated 0x00000000 The objects are unrelated.
QAccessible::Self 0x00000001 The objects are the same.
QAccessible::Ancestor 0x00000002 The first object is a parent of the second object.
QAccessible::Child 0x00000004 The first object is a direct child of the second object.
QAccessible::Descendent 0x00000008 The first object is an indirect child of the second object.
QAccessible::Sibling 0x00000010 The objects are siblings.
QAccessible::Up 0x00000100 The first object is above the second object.
QAccessible::Down 0x00000200 The first object is below the second object.
QAccessible::Left 0x00000400 The first object is left of the second object.
QAccessible::Right 0x00000800 The first object is right of the second object.
QAccessible::Covers 0x00001000 The first object covers the second object.
QAccessible::Covered 0x00002000 The first object is covered by the second object.
QAccessible::FocusChild 0x00010000 The first object is the second object's focus child.
QAccessible::Label 0x00020000 第 1 个对象是第 2 个对象的标签。
QAccessible::Labelled 0x00040000 第 1 个对象被第 2 个对象所标签化。
QAccessible::Controller 0x00080000 第 1 个对象控制第 2 个对象。
QAccessible::Controlled 0x00100000 第 1 个对象被第 2 个对象所控制。

Implementations of relationTo() return a combination of these flags. Some values are mutually exclusive.

Implementations of navigate() can accept only one distinct value.

Relation 类型是 typedef 对于 QFlags <RelationFlag>。它存储 RelationFlag 值的 OR 组合。

enum QAccessible:: Role

此枚举定义可访问对象的角色。角色包括:

常量 描述
QAccessible::AlertMessage 0x00000008 用于提醒用户的对象。
QAccessible::Animation 0x00000036 显示动画的对象。
QAccessible::Application 0x0000000E 应用程序的主窗口。
QAccessible::Assistant 0x00000020 提供交互帮助的对象。
QAccessible::Border 0x00000013 表示边框的对象。
QAccessible::ButtonDropDown 0x00000038 下拉项列表的按钮。
QAccessible::ButtonDropGrid 0x0000003A 下拉栅格的按钮。
QAccessible::ButtonMenu 0x00000039 下拉菜单的按钮。
QAccessible::Canvas 0x00000035 用户可以与之交互,显示图形的对象。
QAccessible::Caret 0x00000007 表示系统插入符号 (文本光标) 的对象。
QAccessible::Cell 0x0000001D 表格中的单元格。
QAccessible::Chart 0x00000011 显示数据图形表示的对象。
QAccessible::CheckBox 0x0000002C 表示可以被复选 (或取消复选) 的选项的对象。某些选项提供混合状态,如:既不复选也不取消复选。
QAccessible::Client 0x0000000A 在窗口中的客户端区域。
QAccessible::Clock 0x0000003D 显示时间的时钟。
QAccessible::Column 0x0000001B 单元格的列,通常在表格中。
QAccessible::ColumnHeader 0x00000019 用于数据列的 Header (头)。
QAccessible::ComboBox 0x0000002E 用户可以从其中选择的抉择列表。
QAccessible::Cursor 0x00000006 表示鼠标光标的对象。
QAccessible::Desktop 0x00000041 表示桌面或工作空间的对象。
QAccessible::Dial 0x00000031 表示表盘或旋钮的对象。
QAccessible::Dialog 0x00000012 对话框。
QAccessible::Document 0x0000000F A document window, usually in an MDI environment.
QAccessible::EditableText 0x0000002A Editable text
QAccessible::Equation 0x00000037 数学方程式表示对象。
QAccessible::Graphic 0x00000028 图形或图片 (如:图标)。
QAccessible::Grip 0x00000004 用户可以拖拽能改变 Widget 大小的握把。
QAccessible::Grouping 0x00000014 表示其它对象逻辑分组的对象。
QAccessible::HelpBalloon 0x0000001F 在单独短期窗口中显示帮助的对象。
QAccessible::HotkeyField 0x00000032 允许用户键入键序列的热键字段。
QAccessible::Indicator 0x00000027 表示当前值或项的指示器。
QAccessible::LayeredPane 0x0000003F 可以包含分层子级的对象 (如:在堆栈中)。
QAccessible::Link 0x0000001E 指向其它内容的链接。
QAccessible::List 0x00000021 用户可从中选择一项或多项的项列表。
QAccessible::ListItem 0x00000022 在项列表中的项。
QAccessible::MenuBar 0x00000002 用户从中打开菜单的菜单栏。
QAccessible::MenuItem 0x0000000C 在菜单或菜单栏中的项。
QAccessible::NoRole 0x00000000 对象没有角色。这通常指示无效对象。
QAccessible::PageTab 0x00000025 用户可以在对话框中选择切换到不同页面的页面选项卡。
QAccessible::PageTabList 0x0000003C 页面选项卡列表。
QAccessible::Pane 0x00000010 通用容器。
QAccessible::PopupMenu 0x0000000B 列表用户可以选择履行动作的选项的菜单。
QAccessible::ProgressBar 0x00000030 正在进行中操作进度的显示对象。
QAccessible::PropertyPage 0x00000026 用户可以在其中改变选项、设置的特性页面。
QAccessible::PushButton 0x0000002B 按钮。
QAccessible::RadioButton 0x0000002D 与其它选项相互排斥的选项的表示对象。
QAccessible::Row 0x0000001C 单元格行 (通常在表格中)。
QAccessible::RowHeader 0x0000001A 用于数据行的 Header (头)。
QAccessible::ScrollBar 0x00000003 允许用户滚动可见区域的滚动条。
QAccessible::Separator 0x00000015 将空间划分成逻辑区域的分隔符。
QAccessible::Slider 0x00000033 允许用户选择给定范围值的滑块。
QAccessible::Sound 0x00000005 表示声音的对象。
QAccessible::SpinBox 0x00000034 允许用户录入给定范围值的自旋框 Widget。
QAccessible::Splitter 0x0000003E 在其子级 Widget 之间分配可用空间的分割器。
QAccessible::StaticText 0x00000029 静态文本 (譬如:其它 Widget 的标签)。
QAccessible::StatusBar 0x00000017 状态栏。
QAccessible::Table 0x00000018 以行、列栅格表示数据的表格。
QAccessible::Terminal 0x00000040 终端或命令行接口。
QAccessible::TitleBar 0x00000001 窗口的标题栏标题。
QAccessible::ToolBar 0x00000016 用于分组用户频繁访问 Widget 的工具栏。
QAccessible::ToolTip 0x0000000D 提供其它对象有关信息的工具提示。
QAccessible::Tree 0x00000023 树结构中的项列表。
QAccessible::TreeItem 0x00000024 树结构中的项。
QAccessible::UserRole 0x0000ffff 要使用的第一值 (对于用户定义角色而言)。
QAccessible::Whitespace 0x0000003B 在其它对象之间的空白空间。
QAccessible::Window 0x00000009 顶层窗口。

enum QAccessible:: StateFlag
flags QAccessible:: State

This enum type defines bit flags that can be combined to indicate the state of an accessible object. The values are:

常量 描述
QAccessible::Animated 0x00004000 The object's appearance changes frequently.
QAccessible::Busy 0x00000800 The object cannot accept input at the moment.
QAccessible::Checked 0x00000010 The object's check box is checked.
QAccessible::Collapsed 0x00000400 The object is collapsed, e.g. a closed listview item, or an iconified window.
QAccessible::DefaultButton 0x00000100 The object represents the default button in a dialog.
QAccessible::Expanded 0x00000200 The object is expandable, and currently the children are visible.
QAccessible::ExtSelectable 0x02000000 The object supports extended selection.
QAccessible::Focusable 0x00100000 The object can receive focus. Only objects in the active window can receive focus.
QAccessible::Focused 0x00000004 The object has keyboard focus.
QAccessible::HasPopup 0x40000000 The object opens a popup.
QAccessible::HotTracked 0x00000080 The object's appearance is sensitive to the mouse cursor position.
QAccessible::Invisible 0x00008000 The object is not visible to the user.
QAccessible::Linked 0x00400000 The object is linked to another object, e.g. a hyperlink.
QAccessible::Marqueed 0x00002000 The object displays scrolling contents, e.g. a log view.
QAccessible::Mixed 0x00000020 The state of the object is not determined, e.g. a tri-state check box that is neither checked nor unchecked.
QAccessible::Modal 0x80000000 The object blocks input from other objects.
QAccessible::Movable 0x00040000 对象可以被移动。
QAccessible::MultiSelectable 0x01000000 The object supports multiple selected items.
QAccessible::Normal 0x00000000 The normal state.
QAccessible::Offscreen 0x00010000 The object is clipped by the visible area. Objects that are off screen are also invisible.
QAccessible::Pressed 0x00000008 The object is pressed.
QAccessible::Protected 0x20000000 The object is password protected, e.g. a line edit for entering a Password.
QAccessible::ReadOnly 0x00000040 The object can usually be edited, but is explicitly set to read-only.
QAccessible::Selectable 0x00200000 对象是可选择的。
QAccessible::Selected 0x00000002 The object is selected.
QAccessible::SelfVoicing 0x00080000 The object describes itself through speech or sound.
QAccessible::Sizeable 0x00020000 The object can be resized, e.g. top-level windows.
QAccessible::Traversed 0x00800000 The object is linked and has been visited.
QAccessible::Unavailable 0x00000001 The object is unavailable to the user, e.g. a disabled widget.

实现的 QAccessibleInterface::state () 返回这些标志的组合。

State 类型是 typedef 对于 QFlags <StateFlag>. It stores an OR combination of StateFlag values.

enum QAccessible:: 文本

此枚举指定可访问对象返回的字符串信息。

常量 描述
QAccessible::Name 0 对象的名称。这可以用作标识符或短描述通过可访问客户端。
QAccessible::Description 1 描述对象的短文字。
QAccessible::Value 2 对象的值。
QAccessible::Help 3 给出如何使用对象的有关信息的更长文本。
QAccessible::Accelerator 4 执行对象默认动作的键盘快捷键。
QAccessible::UserText 0x0000ffff 用于用户定义文本的第一值。

成员函数文档编制

[static] void QAccessible:: installFactory ( InterfaceFactory factory )

安装 InterfaceFactory factory 。最近添加工厂第一个被使用通过 queryAccessibleInterface ().

[static] RootObjectHandler QAccessible:: installRootObjectHandler ( RootObjectHandler handler )

Installs the given handler as the function to be used by setRootObject (), and returns the previously installed handler.

[static] bool QAccessible:: isActive ()

Returns true if an accessibility implementation has been requested during the runtime of the application; otherwise returns false.

Use this function to prevent potentially expensive notifications via updateAccessibility ().

[static] QAccessibleInterface * QAccessible:: queryAccessibleInterface ( QObject * object )

QAccessibleInterface 实现存在为给定 object , this function returns a pointer to the implementation; otherwise it returns 0.

函数调用所有已安装工厂函数 (从最近安装到至少最近安装),直到找到某一提供接口,对于类 object 。若没有工厂可以为类提供可访问性实现,函数将加载已安装的可访问性插件,并测试是否有任何插件可以提供实现。

若对象的类的实现不可用,函数将试着使用以上战略寻找对象的父类的实现。

警告: The caller is responsible for deleting the returned interface after use.

[static] void QAccessible:: removeFactory ( InterfaceFactory factory )

移除 factory 从已安装的 InterfaceFactories 列表。

[static] void QAccessible:: setRootObject ( QObject * object )

Sets the root accessible object of this application to object . All other accessible objects in the application can be reached by the client using object navigation.

You should never need to call this function. Qt sets the QApplication 对象立即作为根对象,之后才进入事件循环在 QApplication::exec ().

使用 QAccessible::installRootObjectHandler () to redirect the function call to a customized handler function.

另请参阅 queryAccessibleInterface ().

[static] void QAccessible:: updateAccessibility ( QObject * object , int child , Event reason )

Notifies accessibility clients about a change in object 's accessibility information.

reason specifies the cause of the change, for example, ValueChange when the position of a slider has been changed. child is the (1-based) index of the child element that has changed. When child is 0, the object itself has changed.

调用此函数,每当可访问对象或其某一子元素的状态以编程方式改变时 (如:通过调用 QLabel::setText ()) 或通过用户交互。

若没有可访问性工具监听此事件,调用此函数的性能损失很小,但是,若确定调用的参数很昂贵,可以测试 isActive () to avoid unnecessary computations.