Home · All Classes · Modules |
The QTextFragment class holds a piece of text in a QTextDocument with a single QTextCharFormat. More...
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.
Creates a new empty text fragment.
Returns the text fragment's character format.
See also text().
See also QTextDocument.allFormats().
Returns the glyphs of this text fragment. The positions of the glyphs are relative to the position of the QTextBlock's layout.
See also QGlyphRun, QTextBlock.layout(), QTextLayout.position(), and QPainter.drawGlyphRun().
Returns the number of characters in the text fragment.
Returns the position of this text fragment in the document.
Returns the text fragment's as plain text.
See also length() and charFormat().
PyQt 4.9.4 for Windows | Copyright © Riverbank Computing Ltd and Nokia 2012 | Qt 4.8.2 |