QAccessibleTextInterface¶
The
QAccessibleTextInterfaceclass implements support for text handling. More…

Detailed Description¶
This interface corresponds to the IAccessibleText interface. It should be implemented for widgets that display more text than a plain label. Labels should be represented by only
QAccessibleInterfaceand return their text as name (text()withNameas type). TheQAccessibleTextInterfaceis typically for text that a screen reader might want to read line by line, and for widgets that support text selection and input. This interface is, for example, implemented forQLineEdit.IAccessible2 Specification
- class PySide2.QtGui.QAccessibleTextInterface¶
- PySide2.QtGui.QAccessibleTextInterface.addSelection(startOffset, endOffset)¶
- Parameters:
startOffset – int
endOffset – int
Select the text from
startOffsettoendOffset. ThestartOffsetis the first character that will be selected. TheendOffsetis the first character that will not be selected.When the object supports multiple selections (e.g. in a word processor), this adds a new selection, otherwise it replaces the previous selection.
The selection will be
endOffset-startOffsetcharacters long.
- PySide2.QtGui.QAccessibleTextInterface.attributes(offset, startOffset, endOffset)¶
- Parameters:
offset – int
startOffset – int
endOffset – int
- Return type:
str
Returns the text attributes at the position
offset. In addition the range of the attributes is returned instartOffsetandendOffset.
- PySide2.QtGui.QAccessibleTextInterface.characterCount()¶
- Return type:
int
Returns the length of the text (total size including spaces).
- PySide2.QtGui.QAccessibleTextInterface.characterRect(offset)¶
- Parameters:
offset – int
- Return type:
Returns the position and size of the character at position
offsetin screen coordinates.
- PySide2.QtGui.QAccessibleTextInterface.cursorPosition()¶
- Return type:
int
Returns the current cursor position.
See also
- PySide2.QtGui.QAccessibleTextInterface.offsetAtPoint(point)¶
- Parameters:
point –
PySide2.QtCore.QPoint- Return type:
int
Returns the offset of the character at the
pointin screen coordinates.
- PySide2.QtGui.QAccessibleTextInterface.removeSelection(selectionIndex)¶
- Parameters:
selectionIndex – int
Clears the selection with index
selectionIndex.
- PySide2.QtGui.QAccessibleTextInterface.scrollToSubstring(startIndex, endIndex)¶
- Parameters:
startIndex – int
endIndex – int
Ensures that the text between
startIndexandendIndexis visible.
- PySide2.QtGui.QAccessibleTextInterface.selection(selectionIndex, startOffset, endOffset)¶
- Parameters:
selectionIndex – int
startOffset – int
endOffset – int
Returns a selection. The size of the selection is returned in
startOffsetandendOffset. If there is no selection bothstartOffsetandendOffsetareNone.The accessibility APIs support multiple selections. For most widgets though, only one selection is supported with
selectionIndexequal to 0.See also
- PySide2.QtGui.QAccessibleTextInterface.selectionCount()¶
- Return type:
int
Returns the number of selections in this text.
- PySide2.QtGui.QAccessibleTextInterface.setCursorPosition(position)¶
- Parameters:
position – int
Moves the cursor to
position.See also
- PySide2.QtGui.QAccessibleTextInterface.setSelection(selectionIndex, startOffset, endOffset)¶
- Parameters:
selectionIndex – int
startOffset – int
endOffset – int
Set the selection
selectionIndexto the range fromstartOffsettoendOffset.See also
- PySide2.QtGui.QAccessibleTextInterface.text(startOffset, endOffset)¶
- Parameters:
startOffset – int
endOffset – int
- Return type:
str
Returns the text from
startOffsettoendOffset. ThestartOffsetis the first character that will be returned. TheendOffsetis the first character that will not be returned.
- PySide2.QtGui.QAccessibleTextInterface.textAfterOffset(offset, boundaryType, startOffset, endOffset)¶
- Parameters:
offset – int
boundaryType –
TextBoundaryTypestartOffset – int
endOffset – int
- Return type:
str
Returns the text item of type
boundaryTypethat is right after offsetoffsetand setsstartOffsetandendOffsetvalues to the start and end positions of that item; returns an empty string if there is no such an item. SetsstartOffsetandendOffsetvalues to -1 on error.This default implementation is provided for small text edits. A word processor or text editor should provide their own efficient implementations. This function makes no distinction between paragraphs and lines.
Note
this function can not take the cursor position into account. By convention an
offsetof -2 means that this function should use the cursor position as offset. Thus an offset of -2 must be converted to the cursor position before calling this function. An offset of -1 is used for the text length and custom implementations of this function have to return the result as if the length was passed in as offset.
- PySide2.QtGui.QAccessibleTextInterface.textAtOffset(offset, boundaryType, startOffset, endOffset)¶
- Parameters:
offset – int
boundaryType –
TextBoundaryTypestartOffset – int
endOffset – int
- Return type:
str
Returns the text item of type
boundaryTypeat offsetoffsetand setsstartOffsetandendOffsetvalues to the start and end positions of that item; returns an empty string if there is no such an item. SetsstartOffsetandendOffsetvalues to -1 on error.This default implementation is provided for small text edits. A word processor or text editor should provide their own efficient implementations. This function makes no distinction between paragraphs and lines.
Note
this function can not take the cursor position into account. By convention an
offsetof -2 means that this function should use the cursor position as offset. Thus an offset of -2 must be converted to the cursor position before calling this function. An offset of -1 is used for the text length and custom implementations of this function have to return the result as if the length was passed in as offset.
- PySide2.QtGui.QAccessibleTextInterface.textBeforeOffset(offset, boundaryType, startOffset, endOffset)¶
- Parameters:
offset – int
boundaryType –
TextBoundaryTypestartOffset – int
endOffset – int
- Return type:
str
Returns the text item of type
boundaryTypethat is close to offsetoffsetand setsstartOffsetandendOffsetvalues to the start and end positions of that item; returns an empty string if there is no such an item. SetsstartOffsetandendOffsetvalues to -1 on error.This default implementation is provided for small text edits. A word processor or text editor should provide their own efficient implementations. This function makes no distinction between paragraphs and lines.
Note
this function can not take the cursor position into account. By convention an
offsetof -2 means that this function should use the cursor position as offset. Thus an offset of -2 must be converted to the cursor position before calling this function. An offset of -1 is used for the text length and custom implementations of this function have to return the result as if the length was passed in as offset.
© 2022 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.