Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QTextBoundaryFinder Class

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

Header:#include <QTextBoundaryFinder>
Since: Qt 4.4

Note: All functions in this class arereentrant.

Public Types

enumBoundaryReason { NotAtBoundary, StartWord, EndWord }
flagsBoundaryReasons
enumBoundaryType { Grapheme, Word, Line, Sentence }

Public Functions

QTextBoundaryFinder()
QTextBoundaryFinder(const QTextBoundaryFinder & other)
QTextBoundaryFinder(BoundaryType type, const QString & string)
QTextBoundaryFinder(BoundaryType type, const QChar * chars, int length, unsigned char * buffer = 0, int bufferSize = 0)
~QTextBoundaryFinder()
BoundaryReasonsboundaryReasons() const
boolisAtBoundary() const
boolisValid() const
intposition() const
voidsetPosition(int position)
QStringstring() const
voidtoEnd()
inttoNextBoundary()
inttoPreviousBoundary()
voidtoStart()
BoundaryTypetype() const
QTextBoundaryFinder &operator=(const QTextBoundaryFinder & other)

Detailed Description

TheQTextBoundaryFinder 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 aQString in four possible modes depending on the value ofBoundaryType.

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.

Member Type Documentation

enum QTextBoundaryFinder::BoundaryReason
flags QTextBoundaryFinder::BoundaryReasons

ConstantValueDescription
QTextBoundaryFinder::NotAtBoundary0The boundary finder is not at a boundary position.
QTextBoundaryFinder::StartWord1The boundary finder is at the start of a word.
QTextBoundaryFinder::EndWord2The boundary finder is at the end of a word.

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

enum QTextBoundaryFinder::BoundaryType

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

Member Function Documentation

QTextBoundaryFinder::QTextBoundaryFinder()

Constructs an invalidQTextBoundaryFinder object.

QTextBoundaryFinder::QTextBoundaryFinder(constQTextBoundaryFinder & other)

Copies theQTextBoundaryFinder object,other.

QTextBoundaryFinder::QTextBoundaryFinder(BoundaryType type, constQString & string)

Creates aQTextBoundaryFinder object oftype operating onstring.

QTextBoundaryFinder::QTextBoundaryFinder(BoundaryType type, constQChar * chars,int length,unsignedchar * buffer = 0,int bufferSize = 0)

Creates aQTextBoundaryFinder object oftype operating onchars withlength.

buffer is an optional working buffer of sizebufferSize you can pass to theQTextBoundaryFinder. If the buffer is large enough to hold the working data required, it will use this instead of allocating its own buffer.

Warning:QTextBoundaryFinder does not create a copy ofchars. It is the application programmer's responsibility to ensure the array is allocated for as long as theQTextBoundaryFinder object stays alive. The same applies tobuffer.

QTextBoundaryFinder::~QTextBoundaryFinder()

Destructs theQTextBoundaryFinder object.

BoundaryReasons QTextBoundaryFinder::boundaryReasons() const

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

bool QTextBoundaryFinder::isAtBoundary() const

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

bool QTextBoundaryFinder::isValid() const

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

int QTextBoundaryFinder::position() const

Returns the current position of theQTextBoundaryFinder.

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

See alsosetPosition().

void QTextBoundaryFinder::setPosition(int position)

Sets the current position of theQTextBoundaryFinder toposition.

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

See alsoposition().

QString QTextBoundaryFinder::string() const

Returns the string theQTextBoundaryFinder object operates on.

void QTextBoundaryFinder::toEnd()

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

See alsosetPosition() andposition().

int QTextBoundaryFinder::toNextBoundary()

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

Returns -1 if there is no next boundary.

int QTextBoundaryFinder::toPreviousBoundary()

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

Returns -1 if there is no previous boundary.

void QTextBoundaryFinder::toStart()

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

See alsosetPosition() andposition().

BoundaryType QTextBoundaryFinder::type() const

Returns the type of theQTextBoundaryFinder.

QTextBoundaryFinder & QTextBoundaryFinder::operator=(constQTextBoundaryFinder & other)

Assigns the object,other, to anotherQTextBoundaryFinder object.

© 2016 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 theGNU 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.


[8]ページ先頭

©2009-2025 Movatter.jp