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

QTextFragment Class

TheQTextFragment class holds a piece of text in aQTextDocument with a singleQTextCharFormat.More...

Header:#include <QTextFragment>

Note: All functions in this class arereentrant.

Public Functions

QTextFragment()
QTextFragment(const QTextFragment & other)
QTextCharFormatcharFormat() const
intcharFormatIndex() const
boolcontains(int position) const
QList<QGlyphRun>glyphRuns() const
boolisValid() const
intlength() const
intposition() const
QStringtext() const
booloperator!=(const QTextFragment & other) const
booloperator<(const QTextFragment & other) const
QTextFragment &operator=(const QTextFragment & other)
booloperator==(const QTextFragment & other) const

Detailed Description

TheQTextFragment class holds a piece of text in aQTextDocument with a singleQTextCharFormat.

A text fragment describes a piece of text that is stored with a single character format. Text in which the character format changes can be represented by sequences of text fragments with different formats.

If the user edits the text in a fragment and introduces a different character format, the fragment's text will be split at each point where the format changes, and new fragments will be created. For example, changing the style of some text in the middle of a sentence will cause the fragment to be broken into three separate fragments: the first and third with the same format as before, and the second with the new style. The first fragment will contain the text from the beginning of the sentence, the second will contain the text from the middle, and the third takes the text from the end of the sentence.

A fragment's text and character format can be obtained with thetext() andcharFormat() functions. Thelength() function gives the length of the text in the fragment.position() gives the position in the document of the start of the fragment. To determine whether the fragment contains a particular position within the document, use thecontains() function.

See alsoQTextDocument andRich Text Document Structure.

Member Function Documentation

QTextFragment::QTextFragment()

Creates a new empty text fragment.

QTextFragment::QTextFragment(constQTextFragment & other)

Copies the content (text and format) of theother text fragment to this text fragment.

QTextCharFormat QTextFragment::charFormat() const

Returns the text fragment's character format.

See alsotext().

int QTextFragment::charFormatIndex() const

Returns an index into the document's internal list of character formats for the text fragment's character format.

See alsoQTextDocument::allFormats().

bool QTextFragment::contains(int position) const

Returns true if the text fragment contains the text at the givenposition in the document; otherwise returns false.

QList<QGlyphRun> QTextFragment::glyphRuns() const

Returns the glyphs of this text fragment. The positions of the glyphs are relative to the position of theQTextBlock's layout.

See alsoQGlyphRun,QTextBlock::layout(),QTextLayout::position(), andQPainter::drawGlyphRun().

bool QTextFragment::isValid() const

Returns true if this is a valid text fragment (i.e. has a valid position in a document); otherwise returns false.

int QTextFragment::length() const

Returns the number of characters in the text fragment.

See alsotext().

int QTextFragment::position() const

Returns the position of this text fragment in the document.

QString QTextFragment::text() const

Returns the text fragment's as plain text.

See alsolength() andcharFormat().

bool QTextFragment::operator!=(constQTextFragment & other) const

Returns true if this text fragment is different (at a different position) from theother text fragment; otherwise returns false.

bool QTextFragment::operator<(constQTextFragment & other) const

Returns true if this text fragment appears earlier in the document than theother text fragment; otherwise returns false.

QTextFragment & QTextFragment::operator=(constQTextFragment & other)

Assigns the content (text and format) of theother text fragment to this text fragment.

bool QTextFragment::operator==(constQTextFragment & other) const

Returns true if this text fragment is the same (at the same position) as theother text fragment; otherwise returns false.

© 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