Home · All Classes · Modules

QTextBoundaryFinder Class Reference
[QtCore module]

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

Types

Methods


Detailed Description

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

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).

QTextBoundaryFinder can operate on a 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.


Type Documentation

QTextBoundaryFinder.BoundaryReason

Constant Value Description
QTextBoundaryFinder.NotAtBoundary 0 The boundary finder is not at a boundary position.
QTextBoundaryFinder.StartWord 1 The boundary finder is at the start of a word.
QTextBoundaryFinder.EndWord 2 The boundary finder is at the end of a word.


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

QTextBoundaryFinder.BoundaryType

Constant Value Description
QTextBoundaryFinder.Grapheme 0 Finds a grapheme which is the smallest boundary. It including letters, punctation marks, numerals and more.
QTextBoundaryFinder.Word 1 Finds a word.
QTextBoundaryFinder.Line 2 Finds possible positions for breaking the text into multiple lines.
QTextBoundaryFinder.Sentence 3 Finds sentence boundaries. These include periods, question marks etc.



Method Documentation

QTextBoundaryFinder.__init__ (self)

Constructs an invalid QTextBoundaryFinder object.

QTextBoundaryFinder.__init__ (self, QTextBoundaryFinder other)

Copies the QTextBoundaryFinder object, other.

QTextBoundaryFinder.__init__ (self, BoundaryType type, QString string)

Creates a QTextBoundaryFinder object of type operating on string.

QTextBoundaryFinder.__init__ (self, BoundaryType type, QChar chars, int length, str buffer = None, int bufferSize = 0)

Creates a QTextBoundaryFinder object of type operating on chars with length.

buffer is an optional working buffer of size bufferSize you can pass to the QTextBoundaryFinder. If the buffer is large enough to hold the working data required, it will use this insetad of allocating it's own buffer.

Warning: QTextBoundaryFinder does not create a copy of chars. It is the application programmer's responsability to ensure the array is allocated for as long as the QTextBoundaryFinder object stays alive. The same applies to buffer.

BoundaryReasons QTextBoundaryFinder.boundaryReasons (self)

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

bool QTextBoundaryFinder.isAtBoundary (self)

Returns true if the object's position() is currently at a valid text boundary.

bool QTextBoundaryFinder.isValid (self)

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

int QTextBoundaryFinder.position (self)

Returns the current position of the QTextBoundaryFinder.

See also setPosition().

QTextBoundaryFinder.setPosition (self, int position)

Sets the current position of the QTextBoundaryFinder to position. If position is out of bounds it will get bound to the valid positions.

See also position().

QString QTextBoundaryFinder.string (self)

Returns the string the QTextBoundaryFinder object operates on.

QTextBoundaryFinder.toEnd (self)

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

See also setPosition() and position().

int QTextBoundaryFinder.toNextBoundary (self)

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

Returns -1 is there is no next boundary.

int QTextBoundaryFinder.toPreviousBoundary (self)

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

Returns -1 is there is no previous boundary.

QTextBoundaryFinder.toStart (self)

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

See also setPosition() and position().

BoundaryType QTextBoundaryFinder.type (self)

Returns the type of the QTextBoundaryFinder.


PyQt 4.4.2 for X11Copyright © Riverbank Computing Ltd and Trolltech AS 2008Qt 4.4.0