Accessible QML 类型

启用 QML 项的可访问性。 更多...

导入语句: import QtQuick 2.15

特性

信号

详细描述

此类属于 Qt Quick 应用程序的可访问性 .

Items the user interacts with or that give information to the user need to expose their information to the accessibility framework. Then assistive tools can make use of that information to enable users to interact with the application in various ways. This enables Qt Quick applications to be used with screen-readers for example.

The most important properties are name , description and role .

简单按钮的范例实现:

Rectangle {
    id: myButton
    Text {
        id: label
        text: "next"
    }
    Accessible.role: Accessible.Button
    Accessible.name: label.text
    Accessible.description: "shows the next page"
    Accessible.onPressAction: {
        // do a button click
    }
}
					

role 被设为 Button to indicate the type of control. name is the most important information and bound to the text on the button. The name is a short and consise description of the control and should reflect the visual label. In this case it is not clear what the button does with the name only, so description contains an explanation. There is also a signal handler Accessible.pressAction which can be invoked by assistive tools to trigger the button. This signal handler needs to have the same effect as tapping or clicking the button would have.

另请参阅 可访问性 .

特性文档编制

checkStateMixed : bool

This property holds whether this item is in the partially checked state.

默认情况下此特性为 false .

另请参阅 checked and checkable .


checkable : bool

This property holds whether this item is checkable (like a check box or some buttons).

默认情况下此特性为 false .

另请参阅 checked .


checked : bool

This property holds whether this item is currently checked.

默认情况下此特性为 false .

另请参阅 checkable .


defaultButton : bool

This property holds whether this item is the default button of a dialog.

默认情况下此特性为 false .


description : string

This property sets an accessible description. Similar to the name it describes the item. The description can be a little more verbose and tell what the item does, for example the functionallity of the button it describes.


editable : bool

This property holds whether this item has editable text.

默认情况下此特性为 false .


focusable : bool

This property holds whether this item is focusable.

默认情况下此特性为 false except for items where the role is one of CheckBox , RadioButton , Button , MenuItem , PageTab , EditableText , SpinBox , ComboBox , 终端 or ScrollBar .

另请参阅 focused .


focused : bool

This property holds whether this item currently has the active focus.

默认情况下此特性为 false , but it will return true for items that have QQuickItem::hasActiveFocus() returning true .

另请参阅 focusable .


ignored : bool

This property holds whether this item should be ignored by the accessibility framework.

Sometimes an item is part of a group of items that should be treated as one. For example two labels might be visually placed next to each other, but separate items. For accessibility purposes they should be treated as one and thus they are represented by a third invisible item with the right geometry.

For example a speed display adds "m/s" as a smaller label:

Row {
    Label {
        id: speedLabel
        text: "Speed: 5"
        Accessible.ignored: true
    }
    Label {
        text: qsTr("m/s")
        Accessible.ignored: true
    }
    Accessible.role: Accessible.StaticText
    Accessible.name: speedLabel.text + " meters per second"
}
					

默认情况下此特性为 false .

该特性在 Qt 5.4 引入。


multiLine : bool

This property holds whether this item has multiple text lines.

默认情况下此特性为 false .


name : string

This property sets an accessible name. For a button for example, this should have a binding to its text. In general this property should be set to a simple and concise but human readable name. Do not include the type of control you want to represent but just the name.


passwordEdit : bool

This property holds whether this item is a password text edit.

默认情况下此特性为 false .


pressed : bool

This property holds whether this item is pressed (for example a button during a mouse click).

默认情况下此特性为 false .


readOnly : bool

This property indicates that a text field is read only.

It is relevant when the role is QAccessible::EditableText and set to be read-only. By default this property is false .


role : enumeration

This flags sets the semantic type of the widget. A button for example would have "Button" as type. The value must be one of QAccessible::Role .

Some roles have special semantics. In order to implement check boxes for example a "checked" property is expected.

角色 特性和信号 解释
All interactive elements focusable and focused All elements that the user can interact with should have focusable set to true and set focus to true when they have the focus. This is important even for applications that run on touch-only devices since screen readers often implement a virtual focus that can be moved from item to item.
Button, CheckBox , RadioButton Accessible.pressAction A button should have a signal handler with the name onPressAction . This signal may be emitted by an assistive tool such as a screen-reader. The implementation needs to behave the same as a mouse click or tap on the button.
CheckBox , RadioButton checkable , checked , Accessible.toggleAction The check state of the check box. Updated on Press, Check and Uncheck actions.
Slider, SpinBox , Dial, ScrollBar , minimumValue , maximumValue , stepSize These properties reflect the state and possible values for the elements.
Slider, SpinBox , Dial, ScrollBar Accessible.increaseAction , Accessible.decreaseAction Actions to increase and decrease the value of the element.

searchEdit : bool

This property holds whether this item is input for a search query. This property will only affect editable text.

默认情况下此特性为 false .


selectable : bool

This property holds whether this item can be selected.

默认情况下此特性为 false .

另请参阅 selected .


selectableText : bool

This property holds whether this item contains selectable text.

默认情况下此特性为 false .


selected : bool

This property holds whether this item is selected.

默认情况下此特性为 false .

另请参阅 selectable .


信号文档编制

decreaseAction ()

This signal is emitted when a decrease action is received from an assistive tool such as a screen-reader.

注意: 相应处理程序是 onDecreaseAction .


increaseAction ()

This signal is emitted when a increase action is received from an assistive tool such as a screen-reader.

注意: 相应处理程序是 onIncreaseAction .


nextPageAction ()

This signal is emitted when a next page action is received from an assistive tool such as a screen-reader.

注意: 相应处理程序是 onNextPageAction .


pressAction ()

This signal is emitted when a press action is received from an assistive tool such as a screen-reader.

注意: 相应处理程序是 onPressAction .


previousPageAction ()

This signal is emitted when a previous page action is received from an assistive tool such as a screen-reader.

注意: 相应处理程序是 onPreviousPageAction .


scrollDownAction ()

This signal is emitted when a scroll down action is received from an assistive tool such as a screen-reader.

注意: 相应处理程序是 onScrollDownAction .


scrollLeftAction ()

This signal is emitted when a scroll left action is received from an assistive tool such as a screen-reader.

注意: 相应处理程序是 onScrollLeftAction .


scrollRightAction ()

This signal is emitted when a scroll right action is received from an assistive tool such as a screen-reader.

注意: 相应处理程序是 onScrollRightAction .


scrollUpAction ()

This signal is emitted when a scroll up action is received from an assistive tool such as a screen-reader.

注意: 相应处理程序是 onScrollUpAction .


toggleAction ()

This signal is emitted when a toggle action is received from an assistive tool such as a screen-reader.

注意: 相应处理程序是 onToggleAction .