内容表

上一话题

QAccessibleEvent

下一话题

QAccessibleObject

QAccessibleInterface

QAccessibleInterface class defines an interface that exposes information about accessible objects. 更多

Inheritance diagram of PySide2.QtGui.QAccessibleInterface

继承者: QAccessibleObject , QAccessibleWidget

概要

虚函数

详细描述

This class is part of Accessibility for QWidget Applications.

可访问性工具 (也称 AT 客户端),譬如:屏幕阅读器或盲文显示,要求应用程序可访问对象的有关高级信息。可访问对象提供专用输入/输出方法,使用户在应用程序启用时 (AT 服务器),能够使用可访问性工具。

用户需要与之交互或作出反应的每个元素都是可访问对象,并应提供此信息。这些主要是视觉对象 (如:Widget 和 Widget 元素),但也可以是内容 (如:声音)。

AT 客户端使用 3 种基本概念,来获取有关应用程序中任何可访问对象的信息:

  • 特性 客户端可以读取可访问对象的有关信息。在某些情况下,客户端还可以修改这些属性 (譬如:在行编辑中的文本)。

  • 动作 客户端可以援引的动作 (像:按下按钮)。

  • 关系和导航 客户端可以从一可访问对象遍历到另一可访问对象,使用对象之间的关系。

QAccessibleInterface defines the API for these three concepts.

关系和导航

函数 childCount() and indexOfChild() return the number of children of an accessible object and the index a child object has in its parent. The childAt() function returns a child QAccessibleInterface that is found at a position. The child does not have to be a direct child. This allows bypassing intermediate layers when the parent already knows the top-most child. childAt() is used for hit testing (finding the object under the mouse).

relations() function provides information about the relations an object has to other objects, and parent() and child() allows traversing from one object to another object.

特性

可访问对象的中心特性是什么 role() it has. Different objects can have the same role, e.g. both the “Add line” element in a scroll bar and the OK button in a dialog have the same role, “button”. The role implies what kind of interaction the user can perform with the user interface element.

An object’s state() property is a combination of different state flags and can describe both how the object’s state differs from a “normal” state, e.g. it might be unavailable, and also how it behaves, e.g. it might be selectable.

text() property provides textual information about the object. An object usually has a name, but can provide extended information such as a description, help text, or information about any keyboard accelerators it provides. Some objects allow changing the text() property through the setText() function, but this information is in most cases read-only.

rect() property provides information about the geometry of an accessible object. This information is usually only available for visual objects.

接口

To enable the user to interact with an accessible object the object must implement QAccessibleActionInterface in addition to QAccessibleInterface . Objects that support selections can define actions to change the selection.

There are several other interfaces that should be implemented as required. QAccessibleTextInterface should be used for bigger texts edits such as document views. This interface should not be implemented for labels/single line edits.

For sliders, scrollbars and other numerical value selectors QAccessibleValueInterface should be implemented.

Lists, tables and trees should implement QAccessibleTableInterface .

另请参阅

QAccessible QAccessibleActionInterface QAccessibleTextInterface QAccessibleValueInterface QAccessibleTableInterface

class QAccessibleInterface
PySide2.QtGui.QAccessibleInterface. backgroundColor ( )
返回类型

QColor

Returns the accessible’s background color if applicable or an invalid QColor .

另请参阅

foregroundColor()

PySide2.QtGui.QAccessibleInterface. child ( index )
参数

index int

返回类型

QAccessibleInterface

返回可访问子级,采用索引 index . 0-based index. The number of children of an object can be checked with childCount .

返回 None when asking for an invalid child (e.g. when the child became invalid in the meantime).

PySide2.QtGui.QAccessibleInterface. childAt ( x , y )
参数
  • x int

  • y int

返回类型

QAccessibleInterface

返回 QAccessibleInterface of a child that contains the screen coordinates ( x , y ). If there are no children at this position this function returns None . The returned accessible must be a child, but not necessarily a direct child.

This function is only relyable for visible objects (invisible object might not be laid out correctly).

所有视觉对象提供此信息。

A default implementation is provided for objects inheriting QAccessibleObject . This will iterate over all children. If the widget manages its children (e.g. a table) it will be more efficient to write a specialized implementation.

另请参阅

rect()

PySide2.QtGui.QAccessibleInterface. childCount ( )
返回类型

int

Returns the number of children that belong to this object. A child can provide accessibility information on its own (e.g. a child widget), or be a sub-element of this accessible object.

所有对象提供此信息。

另请参阅

indexOfChild()

PySide2.QtGui.QAccessibleInterface. editableTextInterface ( )
返回类型

QAccessibleEditableTextInterface

PySide2.QtGui.QAccessibleInterface. focusChild ( )
返回类型

QAccessibleInterface

返回拥有键盘聚焦的对象。

返回对象可以是任何后代,包括自身。

PySide2.QtGui.QAccessibleInterface. foregroundColor ( )
返回类型

QColor

Returns the accessible’s foreground color if applicable or an invalid QColor .

另请参阅

backgroundColor()

PySide2.QtGui.QAccessibleInterface. indexOfChild ( arg__1 )
参数

arg__1 QAccessibleInterface

返回类型

int

Returns the 0-based index of the object child in this object’s children list, or -1 if child is not a child of this object.

All objects provide this information about their children.

另请参阅

childCount()

PySide2.QtGui.QAccessibleInterface. interface_cast ( arg__1 )
参数

arg__1 InterfaceType

返回类型

void

Returns a specialized accessibility interface type from the generic QAccessibleInterface .

This function must be reimplemented when providing more information about a widget or object through the specialized interfaces. For example a line edit should implement the QAccessibleTextInterface .

Qt’s QLineEdit for example has its accessibility support implemented in QAccessibleLineEdit.

void *QAccessibleLineEdit::interface_cast(QAccessible::InterfaceType t)
{
    if (t == QAccessible::TextInterface)
        return static_cast<QAccessibleTextInterface*>(this);
    return QAccessibleWidget::interface_cast(t);
}
												

另请参阅

InterfaceType QAccessibleTextInterface QAccessibleValueInterface QAccessibleActionInterface QAccessibleTableInterface QAccessibleTableCellInterface

PySide2.QtGui.QAccessibleInterface. isValid ( )
返回类型

bool

返回 true if all the data necessary to use this interface implementation is valid (e.g. all pointers are non-null); otherwise returns false .

另请参阅

object()

PySide2.QtGui.QAccessibleInterface. object ( )
返回类型

QObject

返回指针指向 QObject 此接口实现用于提供信息。

另请参阅

isValid()

PySide2.QtGui.QAccessibleInterface. parent ( )
返回类型

QAccessibleInterface

返回 QAccessibleInterface 在可访问对象层次结构中的父级。

返回 None 如果不存在父级 (如:对于顶层应用程序对象而言)。

另请参阅

child()

PySide2.QtGui.QAccessibleInterface. rect ( )
返回类型

QRect

Returns the geometry of the object. The geometry is in screen coordinates.

This function is only reliable for visible objects (invisible objects might not be laid out correctly).

所有视觉对象提供此信息。

另请参阅

childAt()

PySide2.QtGui.QAccessibleInterface. relations ( [ match=QAccessible.AllRelations ] )
参数

match Relation

返回类型

Returns the meaningful relations to other widgets. Usually this will not return parent/child relations, unless they are handled in a specific way such as in tree views. It will typically return the labelled-by and label relations.

It is possible to filter the relations by using match . It should never return itself.

PySide2.QtGui.QAccessibleInterface. role ( )
返回类型

Role

Returns the role of the object. The role of an object is usually static.

所有可访问对象拥有角色。

另请参阅

text() state()

PySide2.QtGui.QAccessibleInterface. setText ( t , text )
参数
  • t 文本

  • text – unicode

设置文本特性 t 的对象到 text .

Note that the text properties of most objects are read-only so calling this function might have no effect.

另请参阅

text()

PySide2.QtGui.QAccessibleInterface. state ( )
返回类型

State

返回对象的当前状态。返回值是 QAccessible::StateFlag 枚举中标志的组合。

所有可访问对象拥有状态。

另请参阅

text() role()

PySide2.QtGui.QAccessibleInterface. tableCellInterface ( )
返回类型

QAccessibleTableCellInterface

PySide2.QtGui.QAccessibleInterface. text ( t )
参数

t 文本

返回类型

unicode

Returns the value of the text property t of the object.

Name is a string used by clients to identify, find, or announce an accessible object for the user. All objects must have a name that is unique within their container. The name can be used differently by clients, so the name should both give a short description of the object and be unique.

An accessible object’s 描述 provides textual information about an object’s visual appearance. The description is primarily used to provide greater context for vision-impaired users, but is also used for context searching or other applications. Not all objects have a description. An “OK” button would not need a description, but a tool button that shows a picture of a smiley would.

of an accessible object represents visual information contained by the object, e.g. the text in a line edit. Usually, the value can be modified by the user. Not all objects have a value, e.g. static text labels don’t, and some objects have a state that already is the value, e.g. toggle buttons.

Help text provides information about the function and usage of an accessible object. Not all objects provide this information.

Accelerator is a keyboard shortcut that activates the object’s default action. A keyboard shortcut is the underlined character in the text of a menu, menu item or widget, and is either the character itself, or a combination of this character and a modifier key like Alt, Ctrl or Shift. Command controls like tool buttons also have shortcut keys and usually display them in their tooltip.

All objects provide a string for Name .

PySide2.QtGui.QAccessibleInterface. textInterface ( )
返回类型

QAccessibleTextInterface

PySide2.QtGui.QAccessibleInterface. valueInterface ( )
返回类型

QAccessibleValueInterface

PySide2.QtGui.QAccessibleInterface. virtual_hook ( id , data )
参数
  • id int

  • data void

Method to allow extending this class without breaking binary compatibility. The actual behavior and format of data depends on id argument which must be defined if the class is to be extended with another virtual function. Currently, this is unused.

PySide2.QtGui.QAccessibleInterface. window ( )
返回类型

QWindow

返回窗口关联的底层对象。例如, QAccessibleWidget 重实现这并返回 windowHandle() 为 QWidget .

It is used on some platforms to be able to notify the AT client about state changes. The backend will traverse up all ancestors until it finds a window. (This means that at least one interface among the ancestors should return a valid QWindow 指针)。

默认实现返回 None .