Qt 4.8
|
The QTextFragment class holds a piece of text in a QTextDocument with a single QTextCharFormat. More...
#include <qtextobject.h>
Public Functions | |
QTextCharFormat | charFormat () const |
Returns the text fragment's character format. More... | |
int | charFormatIndex () const |
Returns an index into the document's internal list of character formats for the text fragment's character format. More... | |
bool | contains (int position) const |
Returns true if the text fragment contains the text at the given position in the document; otherwise returns false. More... | |
QList< QGlyphRun > | glyphRuns () const |
Returns the glyphs of this text fragment. More... | |
bool | isValid () const |
Returns true if this is a valid text fragment (i. More... | |
int | length () const |
Returns the number of characters in the text fragment. More... | |
bool | operator!= (const QTextFragment &o) const |
Returns true if this text fragment is different (at a different position) from the other text fragment; otherwise returns false. More... | |
bool | operator< (const QTextFragment &o) const |
Returns true if this text fragment appears earlier in the document than the other text fragment; otherwise returns false. More... | |
QTextFragment & | operator= (const QTextFragment &o) |
Assigns the content (text and format) of the other text fragment to this text fragment. More... | |
bool | operator== (const QTextFragment &o) const |
Returns true if this text fragment is the same (at the same position) as the other text fragment; otherwise returns false. More... | |
int | position () const |
Returns the position of this text fragment in the document. More... | |
QTextFragment (const QTextDocumentPrivate *priv, int f, int fe) | |
QTextFragment () | |
Creates a new empty text fragment. More... | |
QTextFragment (const QTextFragment &o) | |
Copies the content (text and format) of the other text fragment to this text fragment. More... | |
QString | text () const |
Returns the text fragment's as plain text. More... | |
Properties | |
int | n |
int | ne |
const QTextDocumentPrivate * | p |
The QTextFragment class holds a piece of text in a QTextDocument with a single QTextCharFormat.
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 the text() and charFormat() functions. The length() 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 the contains() function.
Definition at line 297 of file qtextobject.h.
|
inline |
Definition at line 300 of file qtextobject.h.
|
inline |
|
inline |
Copies the content (text and format) of the other text fragment to this text fragment.
Definition at line 302 of file qtextobject.h.
QTextCharFormat QTextFragment::charFormat | ( | ) | const |
Returns the text fragment's character format.
Definition at line 1884 of file qtextobject.cpp.
Referenced by QTextControlPrivate::activateLinkUnderCursor(), QTextControl::anchorPosition(), QTextHtmlExporter::emitFragment(), QTextControl::findNextPrevAnchor(), and QTextOdfWriter::writeInlineCharacter().
int QTextFragment::charFormatIndex | ( | ) | const |
Returns an index into the document's internal list of character formats for the text fragment's character format.
Definition at line 1898 of file qtextobject.cpp.
bool QTextFragment::contains | ( | int | position | ) | const |
Returns true if the text fragment contains the text at the given position in the document; otherwise returns false.
Definition at line 1871 of file qtextobject.cpp.
Returns the glyphs of this text fragment.
The positions of the glyphs are relative to the position of the QTextBlock's layout.
Definition at line 1812 of file qtextobject.cpp.
|
inline |
Returns true if this is a valid text fragment (i.
e. has a valid position in a document); otherwise returns false.
Definition at line 305 of file qtextobject.h.
int QTextFragment::length | ( | ) | const |
Returns the number of characters in the text fragment.
Definition at line 1853 of file qtextobject.cpp.
Referenced by QTextControlPrivate::activateLinkUnderCursor(), and QTextControl::findNextPrevAnchor().
|
inline |
Returns true if this text fragment is different (at a different position) from the other text fragment; otherwise returns false.
Definition at line 308 of file qtextobject.h.
|
inline |
Returns true if this text fragment appears earlier in the document than the other text fragment; otherwise returns false.
Definition at line 309 of file qtextobject.h.
|
inline |
Assigns the content (text and format) of the other text fragment to this text fragment.
Definition at line 303 of file qtextobject.h.
|
inline |
Returns true if this text fragment is the same (at the same position) as the other text fragment; otherwise returns false.
Definition at line 307 of file qtextobject.h.
int QTextFragment::position | ( | ) | const |
Returns the position of this text fragment in the document.
Definition at line 1840 of file qtextobject.cpp.
Referenced by QTextControlPrivate::activateLinkUnderCursor(), QTextControl::anchorPosition(), QTextControl::findNextPrevAnchor(), and operator<().
QString QTextFragment::text | ( | ) | const |
Returns the text fragment's as plain text.
Definition at line 1911 of file qtextobject.cpp.
Referenced by QTextHtmlExporter::emitFragment().
|
private |
Definition at line 325 of file qtextobject.h.
Referenced by operator!=(), operator=(), and operator==().
|
private |
Definition at line 326 of file qtextobject.h.
Referenced by operator=().
|
private |
Definition at line 324 of file qtextobject.h.
Referenced by operator!=(), operator=(), and operator==().