Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

QTextBlock Class Reference

List of all members.

Detailed Description

The QTextBlock class provides a container for text fragments in a QTextDocument.

A text block encapsulates a block or paragraph of text in a QTextDocument. QTextBlock provides read-only access to the block/paragraph structure of QTextDocuments. It is mainly of use if you want to implement your own layouts for the visual representation of a QTextDocument, or if you want to iterate over a document and write out the contents in your own custom format.

Text blocks are created by their parent documents. If you need to create a new text block, or modify the contents of a document while examining its contents, use the cursor-based interface provided by QTextCursor instead.

Each text block is located at a specific position() in a document(). The contents of the block can be obtained by using the text() function. The length() function determines the block's size within the document (including formatting characters). The visual properties of the block are determined by its text layout(), its charFormat(), and its blockFormat().

The next() and previous() functions enable iteration over consecutive valid blocks in a document under the condition that the document is not modified by other means during the iteration process. Note that, although blocks are returned in sequence, adjacent blocks may come from different places in the document structure. The validity of a block can be determined by calling isValid().

QTextBlock provides comparison operators to make it easier to work with blocks: operator==() compares two block for equality, operator!=() compares two blocks for inequality, and operator<() determines whether a block precedes another in the same document.


See also:
QTextBlockFormat QTextCharFormat QTextFragment

Definition at line 197 of file qtextobject.h.

Public Types

typedef iterator Iterator

Public Member Functions

iterator begin () const
QTextBlockFormat blockFormat () const
int blockFormatIndex () const
QTextCharFormat charFormat () const
int charFormatIndex () const
bool contains (int position) const
QTextDocumentPrivate * docHandle () const
const QTextDocumentdocument () const
iterator end () const
bool isValid () const
QTextLayoutlayout () const
int length () const
QTextBlock next () const
bool operator!= (const QTextBlock &o) const
bool operator< (const QTextBlock &o) const
QTextBlockoperator= (const QTextBlock &o)
bool operator== (const QTextBlock &o) const
int position () const
QTextBlock previous () const
 QTextBlock (const QTextBlock &o)
 QTextBlock ()
 QTextBlock (QTextDocumentPrivate *priv, int b)
void setUserData (QTextBlockUserData *data)
void setUserState (int state)
QString text () const
QTextListtextList () const
QTextBlockUserDatauserData () const
int userState () const

Private Attributes

int n
QTextDocumentPrivate * p


class QSyntaxHighlighter
class QTextDocumentPrivate
class QTextLayout


class  iterator
 The QTextBlock::iterator class provides an iterator for reading the contents of a QTextBlock. More...

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index