Table Of Contents

Previous topic

Qt

Next topic

QRectF

QTextBoundaryFinder

Synopsis

Functions

Detailed Description

The PySide.QtCore.QTextBoundaryFinder class provides a way of finding Unicode text boundaries in a string.

PySide.QtCore.QTextBoundaryFinder allows to find Unicode text boundaries in a string, similar to the Unicode text boundary specification (see http://www.unicode.org/reports/tr29/tr29-11.html).

PySide.QtCore.QTextBoundaryFinder can operate on a PySide.QtCore.QString in four possible modes depending on the value of BoundaryType .

Units of Unicode characters that make up what the user thinks of as a character or basic unit of the language are here called Grapheme clusters. The two unicode characters ‘A’ + diaeresis do for example form one grapheme cluster as the user thinks of them as one character, yet it is in this case represented by two unicode code points.

Word boundaries are there to locate the start and end of what a language considers to be a word.

Line break boundaries give possible places where a line break might happen and sentence boundaries will show the beginning and end of whole sentences.

The first position in a string is always a valid boundary and refers to the position before the first character. The last position at the length of the string is also valid and refers to the position after the last character.

class PySide.QtCore.QTextBoundaryFinder
class PySide.QtCore.QTextBoundaryFinder(type, string)
class PySide.QtCore.QTextBoundaryFinder(other)
Parameters:

Constructs an invalid PySide.QtCore.QTextBoundaryFinder object.

Creates a PySide.QtCore.QTextBoundaryFinder object of type operating on string .

Copies the PySide.QtCore.QTextBoundaryFinder object, other .

PySide.QtCore.QTextBoundaryFinder.BoundaryReason
Constant Description
QTextBoundaryFinder.NotAtBoundary The boundary finder is not at a boundary position.
QTextBoundaryFinder.StartWord The boundary finder is at the start of a word.
QTextBoundaryFinder.EndWord The boundary finder is at the end of a word.
PySide.QtCore.QTextBoundaryFinder.BoundaryType
Constant Description
QTextBoundaryFinder.Grapheme Finds a grapheme which is the smallest boundary. It including letters, punctation marks, numerals and more.
QTextBoundaryFinder.Word Finds a word.
QTextBoundaryFinder.Line Finds possible positions for breaking the text into multiple lines.
QTextBoundaryFinder.Sentence Finds sentence boundaries. These include periods, question marks etc.
PySide.QtCore.QTextBoundaryFinder.boundaryReasons()
Return type:PySide.QtCore.QTextBoundaryFinder.BoundaryReasons

Returns the reasons for the boundary finder to have chosen the current position as a boundary.

PySide.QtCore.QTextBoundaryFinder.isAtBoundary()
Return type:PySide.QtCore.bool

Returns true if the object’s PySide.QtCore.QTextBoundaryFinder.position() is currently at a valid text boundary.

PySide.QtCore.QTextBoundaryFinder.isValid()
Return type:PySide.QtCore.bool

Returns true if the text boundary finder is valid; otherwise returns false. A default PySide.QtCore.QTextBoundaryFinder is invalid.

PySide.QtCore.QTextBoundaryFinder.position()
Return type:PySide.QtCore.int

Returns the current position of the PySide.QtCore.QTextBoundaryFinder .

The range is from 0 (the beginning of the string) to the length of the string inclusive.

PySide.QtCore.QTextBoundaryFinder.setPosition(position)
Parameters:positionPySide.QtCore.int

Sets the current position of the PySide.QtCore.QTextBoundaryFinder to position .

If position is out of bounds, it will be bound to only valid positions. In this case, valid positions are from 0 to the length of the string inclusive.

PySide.QtCore.QTextBoundaryFinder.string()
Return type:unicode

Returns the string the PySide.QtCore.QTextBoundaryFinder object operates on.

PySide.QtCore.QTextBoundaryFinder.toEnd()

Moves the finder to the end of the string. This is equivalent to setPosition(string. length() ).

PySide.QtCore.QTextBoundaryFinder.toNextBoundary()
Return type:PySide.QtCore.int

Moves the PySide.QtCore.QTextBoundaryFinder to the next boundary position and returns that position.

Returns -1 if there is no next boundary.

PySide.QtCore.QTextBoundaryFinder.toPreviousBoundary()
Return type:PySide.QtCore.int

Moves the PySide.QtCore.QTextBoundaryFinder to the previous boundary position and returns that position.

Returns -1 if there is no previous boundary.

PySide.QtCore.QTextBoundaryFinder.toStart()

Moves the finder to the start of the string. This is equivalent to setPosition(0).

PySide.QtCore.QTextBoundaryFinder.type()
Return type:PySide.QtCore.QTextBoundaryFinder.BoundaryType

Returns the type of the PySide.QtCore.QTextBoundaryFinder .