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
| Constant | Value | Description |
|---|---|---|
QTextBoundaryFinder::NotAtBoundary | 0 | The boundary finder is not at a boundary position. |
QTextBoundaryFinder::BreakOpportunity | 0x1f | The 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::StartOfItem | 0x20 | Since 5.0. The boundary finder is at the start of a grapheme, a word, a sentence, or a line. |
QTextBoundaryFinder::EndOfItem | 0x40 | Since 5.0. The boundary finder is at the end of a grapheme, a word, a sentence, or a line. |
QTextBoundaryFinder::MandatoryBreak | 0x80 | Since 5.0. The boundary finder is at the end of line (can occur for a Line boundary type only). |
QTextBoundaryFinder::SoftHyphen | 0x100 | The boundary finder is at the soft hyphen (can occur for a Line boundary type only). |
enum QTextBoundaryFinder::BoundaryType
| Constant | Value | Description |
|---|---|---|
QTextBoundaryFinder::Grapheme | 0 | Finds a grapheme which is the smallest boundary. It including letters, punctuation marks, numerals and more. |
QTextBoundaryFinder::Word | 1 | Finds a word. |
QTextBoundaryFinder::Line | 3 | Finds possible positions for breaking the text into multiple lines. |
QTextBoundaryFinder::Sentence | 2 | Finds sentence boundaries. These include periods, question marks etc. |