Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

QTextFragment Class Reference

The QTextFragment class holds a piece of text in a QTextDocument that has a single QTextCharFormat. More...

#include <QTextFragment>

List of all members.

Public Functions


Detailed Description

The QTextFragment class holds a piece of text in a QTextDocument that has a single QTextCharFormat.

If the user edits the text in a fragment, for example, makes a word in the middle bold, the fragment will be broken into three separate fragments, the first and third with the same format as before and containing the text before and after the emboldened word, and the second with a bold font and the emboldened word.

A text fragment can be queried for its text(), charFormat(), length() and position(), and for whether it contains() a particular position in the document as a whole.


Member Function Documentation

QTextFragment::QTextFragment ()

Creates a new empty text fragment.

QTextFragment::QTextFragment ( const QTextFragment & other )

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

QTextCharFormat QTextFragment::charFormat () const

Returns the text fragment's character format.

See also text().

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.

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 also text().

int QTextFragment::position () const

Returns the position of this text fragment in the document.

QString QTextFragment::text () const

Returns the text fragment's text.

See also length() and charFormat().

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

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

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

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

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

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

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

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


Copyright © 2004 Trolltech. Trademarks
Qt 4.0.0-tp1