QTextBoundaryFinder Class

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

Header: #include <QTextBoundaryFinder>
qmake: QT += core
Since: Qt 4.4

This class was introduced in Qt 4.4.

Note: All functions in this class are reentrant.

Public Types

enum BoundaryReason { NotAtBoundary, BreakOpportunity, StartOfItem, EndOfItem, MandatoryBreak, SoftHyphen }
enum BoundaryType { Grapheme, Word, Line, Sentence }

Detailed Description

QTextBoundaryFinder allows to find Unicode text boundaries in a string, accordingly to the Unicode text boundary specification (see Unicode Standard Annex #14 and Unicode Standard Annex #29).

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 (see https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries).

Word boundaries are there to locate the start and end of what a language considers to be a word (see https://www.unicode.org/reports/tr29/#Word_Boundaries).

Line break boundaries give possible places where a line break might happen and sentence boundaries will show the beginning and end of whole sentences (see https://www.unicode.org/reports/tr29/#Sentence_Boundaries and https://www.unicode.org/reports/tr14/).

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.

Member Type Documentation

enum QTextBoundaryFinder::BoundaryReason

ConstantValueDescription
QTextBoundaryFinder::NotAtBoundary0The boundary finder is not at a boundary position.
QTextBoundaryFinder::BreakOpportunity0x1fThe boundary finder is at a break opportunity position. Such a break opportunity might also be an item boundary (either StartOfItem, EndOfItem, or combination of both), a mandatory line break, or a soft hyphen.
QTextBoundaryFinder::StartOfItem0x20Since 5.0. The boundary finder is at the start of a grapheme, a word, a sentence, or a line.
QTextBoundaryFinder::EndOfItem0x40Since 5.0. The boundary finder is at the end of a grapheme, a word, a sentence, or a line.
QTextBoundaryFinder::MandatoryBreak0x80Since 5.0. The boundary finder is at the end of line (can occur for a Line boundary type only).
QTextBoundaryFinder::SoftHyphen0x100The boundary finder is at the soft hyphen (can occur for a Line boundary type only).

enum QTextBoundaryFinder::BoundaryType

ConstantValueDescription
QTextBoundaryFinder::Grapheme0Finds a grapheme which is the smallest boundary. It including letters, punctuation marks, numerals and more.
QTextBoundaryFinder::Word1Finds a word.
QTextBoundaryFinder::Line3Finds possible positions for breaking the text into multiple lines.
QTextBoundaryFinder::Sentence2Finds sentence boundaries. These include periods, question marks etc.