QAccessibleClient::AccessibleObject Class

This class represents an accessible object. More...

Header: #include <AccessibleObject>
CMake: find_package(QAccessibilityClient REQUIRED)
target_link_libraries(mytarget PRIVATE QAccessibilityClient::QAccessibilityClient)

Public Types

enum Interface { NoInterface, AccessibleInterface, CacheInterface, ActionInterface, ApplicationInterface, …, InvalidInterface }
flags Interfaces
enum LocaleType { LocaleTypeMessages, LocaleTypeCollate, LocaleTypeCType, LocaleTypeMonetary, LocaleTypeNumeric, LocaleTypeTime }
enum Role { NoRole, CheckBox, CheckableMenuItem, ColumnHeader, ComboBox, …, TreeIte }
enum TextBoundary { CharBoundary, WordStartBoundary, WordEndBoundary, SentenceStartBoundary, SentenceEndBoundary, …, LineEndBoundar }

Public Functions

AccessibleObject()
AccessibleObject(const QAccessibleClient::AccessibleObject &other)
~AccessibleObject()
QString accessibleId() const
QVector<QSharedPointer<QAction>> actions() const
double alpha() const
QString appBusAddress() const
int appId() const
QString appLocale(QAccessibleClient::AccessibleObject::LocaleType lctype = LocaleTypeMessages) const
QString appToolkitName() const
QString appVersion() const
QAccessibleClient::AccessibleObject application() const
QRect boundingRect() const
int caretOffset() const
int characterCount() const
QRect characterRect(int offset) const
QAccessibleClient::AccessibleObject child(int index) const
int childCount() const
QList<QAccessibleClient::AccessibleObject> children() const
QVector<QList<QAccessibleClient::AccessibleObject>> children(const QList<QAccessibleClient::AccessibleObject::Role> &roles) const
bool copyText(int startPos, int endPos)
double currentValue() const
bool cutText(int startPos, int endPos)
bool deleteText(int startPos, int endPos)
QString description() const
QPoint focusPoint() const
bool hasSelectableText() const
bool hasToolTip() const
QString id() const
QString imageDescription() const
QString imageLocale() const
QRect imageRect() const
int indexInParent() const
bool insertText(const QString &text, int position = 0, int length = -1)
bool isActive() const
bool isCheckable() const
bool isChecked() const
bool isDefault() const
bool isDefunct() const
bool isEditable() const
bool isEnabled() const
bool isExpandable() const
bool isExpanded() const
bool isFocusable() const
bool isFocused() const
bool isMultiLine() const
bool isSelectable() const
bool isSelected() const
bool isSensitive() const
bool isSingleLine() const
bool isValid() const
bool isVisible() const
int layer() const
QString localizedRoleName() const
double maximumValue() const
int mdiZOrder() const
double minimumValue() const
double minimumValueIncrement() const
QString name() const
QAccessibleClient::AccessibleObject parent() const
bool pasteText(int position)
QAccessibleClient::AccessibleObject::Role role() const
QString roleName() const
QList<QAccessibleClient::AccessibleObject> selection() const
bool setCurrentValue(const double value)
bool setText(const QString &text)
void setTextSelections(const QList<QPair<int, int>> &selections)
QString stateString() const
QAccessibleClient::AccessibleObject::Interfaces supportedInterfaces() const
bool supportsAutocompletion() const
QString text(int startOffset = 0, int endOffset = -1) const
QList<QPair<int, int>> textSelections() const
QString textWithBoundary(int offset, QAccessibleClient::AccessibleObject::TextBoundary boundary, int *startOffset = nullptr, int *endOffset = nullptr) const
QUrl url() const
bool operator!=(const QAccessibleClient::AccessibleObject &other) const
QAccessibleClient::AccessibleObject &operator=(const QAccessibleClient::AccessibleObject &other)
bool operator==(const QAccessibleClient::AccessibleObject &other) const

Detailed Description

An accessible object equals usually a visible widget or some kind of other element the user can interact with but can also present a not visible object that offers certain functionality like for example actions which can be triggered.

It is implicitly shared and only created by the library.

Member Type Documentation

enum AccessibleObject::Interface
flags AccessibleObject::Interfaces

This enum describes the different interfaces that an AccessibleObject can implement.

Each AccessibleObject must implement the AccessibleInterface, otherwise it is invalid. All other interfaces are optional.

If the ActionInterface is implement the object will have a list of actions that can be invoked.

ConstantValue
QAccessibleClient::AccessibleObject::NoInterface0x0
QAccessibleClient::AccessibleObject::AccessibleInterface0x1
QAccessibleClient::AccessibleObject::CacheInterface0x2
QAccessibleClient::AccessibleObject::ActionInterface0x4
QAccessibleClient::AccessibleObject::ApplicationInterface0x8
QAccessibleClient::AccessibleObject::CollectionInterface0x10
QAccessibleClient::AccessibleObject::ComponentInterface0x20
QAccessibleClient::AccessibleObject::DocumentInterface0x40
QAccessibleClient::AccessibleObject::EditableTextInterface0x80
QAccessibleClient::AccessibleObject::EventKeyboardInterface0x100
QAccessibleClient::AccessibleObject::EventMouseInterface0x200
QAccessibleClient::AccessibleObject::EventObjectInterface0x400
QAccessibleClient::AccessibleObject::HyperlinkInterface0x800
QAccessibleClient::AccessibleObject::HypertextInterface0x1000
QAccessibleClient::AccessibleObject::ImageInterface0x2000
QAccessibleClient::AccessibleObject::SelectionInterface0x4000
QAccessibleClient::AccessibleObject::TableInterface0x8000
QAccessibleClient::AccessibleObject::TextInterface0x10000
QAccessibleClient::AccessibleObject::ValueInterface0x20000
QAccessibleClient::AccessibleObject::SocketInterface0x40000
QAccessibleClient::AccessibleObject::EventWindowInterface0x80000
QAccessibleClient::AccessibleObject::EventFocusInterface0x100000
QAccessibleClient::AccessibleObject::InvalidInterface0x80000000

The Interfaces type is a typedef for QFlags<Interface>. It stores an OR combination of Interface values.

enum AccessibleObject::LocaleType

The type of locale.

ConstantValue
QAccessibleClient::AccessibleObject::LocaleTypeMessages0
QAccessibleClient::AccessibleObject::LocaleTypeCollate1
QAccessibleClient::AccessibleObject::LocaleTypeCType2
QAccessibleClient::AccessibleObject::LocaleTypeMonetary3
QAccessibleClient::AccessibleObject::LocaleTypeNumeric4
QAccessibleClient::AccessibleObject::LocaleTypeTime5

enum AccessibleObject::Role

The role indicates the type of UI element that an AccessibleObject represents.

ConstantValueDescription
QAccessibleClient::AccessibleObject::NoRole0The object is invalid and has no role set. This is generally a bug.
QAccessibleClient::AccessibleObject::CheckBox1 
QAccessibleClient::AccessibleObject::CheckableMenuItem2 
QAccessibleClient::AccessibleObject::ColumnHeader3 
QAccessibleClient::AccessibleObject::ComboBox4 
QAccessibleClient::AccessibleObject::DesktopFrame5 
QAccessibleClient::AccessibleObject::Dial6 
QAccessibleClient::AccessibleObject::Dialog7 
QAccessibleClient::AccessibleObject::Filler8 
QAccessibleClient::AccessibleObject::Frame9 
QAccessibleClient::AccessibleObject::Icon10 
QAccessibleClient::AccessibleObject::Label11 
QAccessibleClient::AccessibleObject::ListView12 
QAccessibleClient::AccessibleObject::ListItem13 
QAccessibleClient::AccessibleObject::Menu14 
QAccessibleClient::AccessibleObject::MenuBar15 
QAccessibleClient::AccessibleObject::MenuItem16 
QAccessibleClient::AccessibleObject::Tab17 
QAccessibleClient::AccessibleObject::TabContainer18 
QAccessibleClient::AccessibleObject::PasswordText19 
QAccessibleClient::AccessibleObject::PopupMenu20 
QAccessibleClient::AccessibleObject::ProgressBar21 
QAccessibleClient::AccessibleObject::Button22 
QAccessibleClient::AccessibleObject::RadioButton23 
QAccessibleClient::AccessibleObject::RadioMenuItem24 
QAccessibleClient::AccessibleObject::RowHeader25 
QAccessibleClient::AccessibleObject::ScrollBar26 
QAccessibleClient::AccessibleObject::ScrollArea27 
QAccessibleClient::AccessibleObject::Separator28 
QAccessibleClient::AccessibleObject::Slider29 
QAccessibleClient::AccessibleObject::SpinButton30 
QAccessibleClient::AccessibleObject::StatusBar31 
QAccessibleClient::AccessibleObject::TableView32 
QAccessibleClient::AccessibleObject::TableCell33 
QAccessibleClient::AccessibleObject::TableColumnHeader34 
QAccessibleClient::AccessibleObject::TableColumn35 
QAccessibleClient::AccessibleObject::TableRowHeader36 
QAccessibleClient::AccessibleObject::TableRow37 
QAccessibleClient::AccessibleObject::Terminal38 
QAccessibleClient::AccessibleObject::Text39 
QAccessibleClient::AccessibleObject::ToggleButton40 
QAccessibleClient::AccessibleObject::ToolBar41 
QAccessibleClient::AccessibleObject::ToolTip42 
QAccessibleClient::AccessibleObject::TreeView43 
QAccessibleClient::AccessibleObject::Window44 
QAccessibleClient::AccessibleObject::TreeIte? 

enum AccessibleObject::TextBoundary

The TextBoundaries enum represents the different boundaries when asking for text at a certain offset.

ConstantValue
QAccessibleClient::AccessibleObject::CharBoundary0
QAccessibleClient::AccessibleObject::WordStartBoundary1
QAccessibleClient::AccessibleObject::WordEndBoundary2
QAccessibleClient::AccessibleObject::SentenceStartBoundary3
QAccessibleClient::AccessibleObject::SentenceEndBoundary4
QAccessibleClient::AccessibleObject::LineStartBoundary5
QAccessibleClient::AccessibleObject::LineEndBoundar?

Member Function Documentation

AccessibleObject::AccessibleObject()

Construct an invalid AccessibleObject.

AccessibleObject::AccessibleObject(const QAccessibleClient::AccessibleObject &other)

Copy constructor.

[noexcept] AccessibleObject::~AccessibleObject()

Destroys the AccessibleObject.

QString AccessibleObject::accessibleId() const

Returns the accessible id of this accessible.

This is an id which is stable over application development. It may be empty.

QVector<QSharedPointer<QAction>> AccessibleObject::actions() const

Returns a list of actions supported by this accessible.

Just trigger() the action to execute the underlying method at the accessible.

double AccessibleObject::alpha() const

Obtain the alpha value of the component.

An alpha value of 1.0 or greater indicates that the object is fully opaque, and an alpha value of 0.0 indicates that the object is fully transparent. Negative alpha values have no defined meaning at this time.

Alpha values are used in conjunction with Z-order calculations to determine whether an object wholly or partially obscures another object's visual intersection, in the event that their bounds intersect.

QString AccessibleObject::appBusAddress() const

The application D-Bus address.

int AccessibleObject::appId() const

Returns the unique application identifier.

The identifier will not last over the session and every time the app quits and restarts it gets another identifier that persists as long as the application is running.

QString AccessibleObject::appLocale(QAccessibleClient::AccessibleObject::LocaleType lctype = LocaleTypeMessages) const

The application locale.

Returns a string compliant with the POSIX standard for the locale description.

The locale will be queried against the LocaleType lctype.

QString AccessibleObject::appToolkitName() const

Returns the toolkit name.

This can be for example "Qt" or "gtk".

QString AccessibleObject::appVersion() const

Returns the toolkit version.

This can be for example "4.8.3" for Qt 4.8.3.

QAccessibleClient::AccessibleObject AccessibleObject::application() const

Returns the application object.

Returns the top-level application object that expose an org.a11y.atspi.Application accessibility interface.

QRect AccessibleObject::boundingRect() const

Returns a bounding rectangle for the accessible.

This can be used to get the focus coordinates.

int AccessibleObject::caretOffset() const

Returns the offset of the caret from the beginning of the text.

This function provides the current offset of the caret from the beginning of the text in an accessible that implements org.a11y.atspi.Text.

int AccessibleObject::characterCount() const

Returns the number of characters.

QRect AccessibleObject::characterRect(int offset) const

Returns a bounding rectangle for the character at position offset.

This function is only supported for accessibles that implement the text interface. It will return an empty rectangle for invalid offsets or accessibles.

QAccessibleClient::AccessibleObject AccessibleObject::child(int index) const

Returns a specific child at position index.

The list of children is 0-based.

int AccessibleObject::childCount() const

Returns the number of children for this accessible.

QList<QAccessibleClient::AccessibleObject> AccessibleObject::children() const

Returns this accessible's children in a list.

QVector<QList<QAccessibleClient::AccessibleObject>> AccessibleObject::children(const QList<QAccessibleClient::AccessibleObject::Role> &roles) const

Returns this accessible's children according to their roles.

Returns a vector that contains the children of this object according to there roles. The number of vector-items equals to the number and sorting of the roles items.

Example usage:

QList<Role> roles;
roles << Label << CheckBox;
QVector< QList<AccessibleObject> > c = children(roles);
Q_ASSERT(c.count() == roles.count());
Q_ASSERT(c[0].isEmpty() || c[0].first().role() == Label);
Q_ASSERT(c[1].isEmpty() || c[1].first().role() == CheckBox);

bool AccessibleObject::copyText(int startPos, int endPos)

Copy the text from the EditableTextInterface into the clipboard starting from the caret position startPos until endPos.

Returns true on success, false otherwise.

double AccessibleObject::currentValue() const

The current value of the valuator.

This is the value the org.a11y.atspi.Value accessibility interface has.

See also setCurrentValue().

bool AccessibleObject::cutText(int startPos, int endPos)

Cut the text from the EditableTextInterface into the clipboard starting from the caret position startPos until endPos.

Returns true on success, false otherwise.

bool AccessibleObject::deleteText(int startPos, int endPos)

Delete the text from the EditableTextInterface starting from the caret position startPos until endPos.

Returns true on success, false otherwise.

QString AccessibleObject::description() const

Returns the description for this accessible.

The description is more of an explanation than the name. This can be a sentence. The string is localized.

QPoint AccessibleObject::focusPoint() const

Returns the focus point of the object.

bool AccessibleObject::hasSelectableText() const

Returns if the AccessibleObject allows text selections.

bool AccessibleObject::hasToolTip() const

Returns if the AccessibleObject has a tool tip.

QString AccessibleObject::id() const

Returns a unique identifier for the object.

QString AccessibleObject::imageDescription() const

A description text of the image.

It is recommended that imageDescription be the shorter of the available image descriptions, for instance "alt text" in HTML images, and a longer description be provided in QAccessible::Description, if available. A short, one or two word label for the image should be provided in QAccessible::Name.

Returns a UTF-8 string providing a textual description of what is visually depicted in the image.

QString AccessibleObject::imageLocale() const

The locale of the image.

Returns a string corresponding to the POSIX LC_MESSAGES locale used by the imageDescription.

QRect AccessibleObject::imageRect() const

The image boundaries.

Obtain a bounding box which entirely contains the image contents, as displayed on screen.

The bounds returned do not account for any viewport clipping or the fact that the image may be partially or wholly obscured by other onscreen content.

This method returns the bounds of the current onscreen view, and not the nominal size of the source data in the event that the original image has been rescaled.

Returns a BoundingBox enclosing the image's onscreen representation.

int AccessibleObject::indexInParent() const

Returns this accessible's index in its parent's list of children.

bool AccessibleObject::insertText(const QString &text, int position = 0, int length = -1)

Inserts text into the EditableTextInterface at caret position with the given length.

bool AccessibleObject::isActive() const

Returns if the AccessibleObject is currently active.

bool AccessibleObject::isCheckable() const

Returns if the AccessibleObject is checkable (often indicates a check action).

bool AccessibleObject::isChecked() const

Returns if the AccessibleObject is currently checked.

bool AccessibleObject::isDefault() const

Returns if the AccessibleObject is the default widget (e.g. a button in a dialog).

bool AccessibleObject::isDefunct() const

Returns if the AccessibleObject is defunct. That means it does not properly respond to requests and should be ignored for accessibility purposes.

bool AccessibleObject::isEditable() const

Returns if the AccessibleObject is an editable text.

bool AccessibleObject::isEnabled() const

Returns if the AccessibleObject is currently enabled.

bool AccessibleObject::isExpandable() const

Returns if the AccessibleObject can be expanded to show more information.

bool AccessibleObject::isExpanded() const

Returns if the AccessibleObject is currently expanded.

bool AccessibleObject::isFocusable() const

Returns if the AccessibleObject is focusable.

bool AccessibleObject::isFocused() const

Returns if the AccessibleObject is currently focused.

bool AccessibleObject::isMultiLine() const

Returns if the AccessibleObject is a multiline text edit.

bool AccessibleObject::isSelectable() const

Returns if the AccessibleObject is selectable.

bool AccessibleObject::isSelected() const

Returns if the AccessibleObject is currently selected.

bool AccessibleObject::isSensitive() const

Returns if the AccessibleObject reacts to input events.

bool AccessibleObject::isSingleLine() const

Returns if the AccessibleObject is a single line text edit.

bool AccessibleObject::isValid() const

Returns true if this object is valid.

Invalid objects are for example returned when asking for the parent of the top most item, or for a child that is out of range.

bool AccessibleObject::isVisible() const

Returns if the AccessibleObject is currently visible (it can still be off the screen, but there is nothing preventing the user from seeing it in general).

int AccessibleObject::layer() const

The ComponentLayer in which this object resides.

QString AccessibleObject::localizedRoleName() const

Returns the name of the role of this accessible.

This name is localized and can be presented to the user.

double AccessibleObject::maximumValue() const

The maximum value allowed by this valuator.

If both, the minimumValue and maximumValue, are zero then there is no minimum or maximum values. The currentValue has no range restrictions.

int AccessibleObject::mdiZOrder() const

Obtain the relative stacking order ('Z' order) of an object.

Larger values indicate that an object is on "top" of the stack, therefore objects with smaller MDIZOrder may be obscured by objects with a larger MDIZOrder, but not vice-versa.

double AccessibleObject::minimumValue() const

The minimum value allowed by this valuator.

If both, the minimumValue and maximumValue are zero then there are no minimum or maximum values. The currentValue has no range restrictions.

double AccessibleObject::minimumValueIncrement() const

The smallest incremental change which this valuator allows.

This is a helper value to know in what steps the currentValue is incremented or decremented.

If 0, the incremental changes to the valuator are limited only by the precision of a double precision value on the platform.

QString AccessibleObject::name() const

Returns the name of this accessible.

The name is a short descriptive one or two words. It is localized.

QAccessibleClient::AccessibleObject AccessibleObject::parent() const

Returns this object's parent.

bool AccessibleObject::pasteText(int position)

Paste the text from the clipboard into the EditableTextInterface at the given caret position.

Returns true on success, false otherwise.

QAccessibleClient::AccessibleObject::Role AccessibleObject::role() const

Returns the role as integer value of this accessible.

QString AccessibleObject::roleName() const

Returns the name of the role of this accessible.

This name is not localized to allow tools to work with the English string.

QList<QAccessibleClient::AccessibleObject> AccessibleObject::selection() const

Returns the selection of accessible objects.

bool AccessibleObject::setCurrentValue(const double value)

Sets the value of the valuator.

Returns true on success, false otherwise.

See also currentValue().

bool AccessibleObject::setText(const QString &text)

Sets the text of the EditableTextInterface.

Returns true on success, false otherwise.

See also text().

void AccessibleObject::setTextSelections(const QList<QPair<int, int>> &selections)

Sets text selections.

Usually only one selection will be set, use a list of QPairs with the start and end offsets for that.

See also textSelections().

QString AccessibleObject::stateString() const

Return a string representing states of this object.

This is useful for debugging applications.

QAccessibleClient::AccessibleObject::Interfaces AccessibleObject::supportedInterfaces() const

Returns a QStringList of interfaces supported by the accessible.

This function provides a list of accessible interfaces that are implemented by an accessible object. This can be used to avoid calling functions that are not supported by the accessible.

bool AccessibleObject::supportsAutocompletion() const

Returns if the AccessibleObject supports automatic text completion.

QString AccessibleObject::text(int startOffset = 0, int endOffset = -1) const

Returns the text of the TextInterface.

This function provides the current text as displayed by the org.a11y.atspi.Text TextInterface component.

startOffset The start caret offset to return the text from.

endOffset The end caret offset to return the text from. If -1 then the endOffset is the end of the string what means all characters are included.

See also setText().

QList<QPair<int, int>> AccessibleObject::textSelections() const

Returns a list of selections the text has.

Every item in that list is a pair of integers representing startOffset and endOffset of the selection.

Code to demonstrate usage:

QList< QPair<int,int> > sel = acc.textSelections();
int startOffset = sel[0].first;
int endOffset = sel[0].second;
QString allText = acc.text();
QString selText = allText.mid(startOffset, endOffset - startOffset);

See also setTextSelections().

QString AccessibleObject::textWithBoundary(int offset, QAccessibleClient::AccessibleObject::TextBoundary boundary, int *startOffset = nullptr, int *endOffset = nullptr) const

Returns the text of the TextInterface by boundary.

Especially for larger text fields it may be more performant and easier to query the text at a certain position instead of the full text.

For example the line where the cursor is currently can be retrieved with this function in a convenient way.

offset The position of the requested text.

startOffset The beginning of the offset, for example the start of the line when asking for line boundaries.

endOffset The end of the text section

QUrl AccessibleObject::url() const

Returns a QUrl that references the AccessibleObject.

This can be used to serialize/deserialize an AccessibleObject to pass it around as string and restore the AccessibleObject by using Registry::accessibleFromUrl later on.

The returned QUrl returns a scheme of "accessibleobject", the D-Bus path as url path and the D-Bus service as url fragment.

bool AccessibleObject::operator!=(const QAccessibleClient::AccessibleObject &other) const

Inequality operator.

QAccessibleClient::AccessibleObject &AccessibleObject::operator=(const QAccessibleClient::AccessibleObject &other)

Assignment operator.

bool AccessibleObject::operator==(const QAccessibleClient::AccessibleObject &other) const

Comparison operator.