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

# QAbstractTextDocumentLayout Class Reference

The QAbstractTextDocumentLayout class is an abstract base class used to implement custom layouts for QTextDocuments. More...

    #include <QAbstractTextDocumentLayout>

This class is under development and is subject to change.

Inherits QObject.

- List of all members, including inherited members

### Writable Properties

- 1 writable property inherited from QObject

### Public Functions

- QAbstractTextDocumentLayout ( QTextDocument * document )
- QString anchorAt ( const QPoint & position ) const
- QFont defaultFont () const
- virtual void documentChange ( int from, int oldLength, int length ) = 0
- virtual void draw ( QPainter * painter, const PaintContext & context ) = 0
- virtual void drawObject ( QPainter * painter, const QRectF & rect, QTextInlineObject object, const QTextFormat & format, QTextLayout::SelectionType selection )
- virtual QRect frameBoundingRect ( QTextFrame * frame ) const
- virtual int hitTest ( const QPoint & point, Qt::HitTestAccuracy accuracy ) const = 0
- virtual void layoutObject ( QTextInlineObject item, const QTextFormat & format )
- virtual int numPages () const = 0
- virtual QSize pageSize () const = 0
- void setDefaultFont ( const QFont & font )
- virtual void setPageSize ( const QSize & size ) = 0
- virtual void setSize ( QTextInlineObject item, const QTextFormat & format )
- virtual QSize sizeUsed () const

- 26 public functions inherited from QObject

### Public Slots

- 1 public slot inherited from QObject

### Signals

- void update ( const QRect & rect = QRect( 0, 0, 0x10000000, 0x10000000 ) )

- 1 signal inherited from QObject

### Static Public Members

- 4 static public members inherited from QObject

### Protected Functions

- const QTextDocument * document () const
- QTextCharFormat format ( int position )

- 7 protected functions inherited from QObject

## Detailed Description

The QAbstractTextDocumentLayout class is an abstract base class used to implement custom layouts for QTextDocuments.

The standard layout provided by Qt can handle simple word processing including inline layouts, lists and tables.

Some applications (e.g. a word processor or a DTP application) might need more features than the ones provided by Qt's layout engine, in which case you can subclass QAbstractTextDocumentLayout to provide your own custom layout behavior for your text documents.

## Member Function Documentation

### QAbstractTextDocumentLayout::QAbstractTextDocumentLayout ( QTextDocument * document )

Creates a new text document layout for the given document.

### QString QAbstractTextDocumentLayout::anchorAt ( const QPoint & position ) const

Returns the reference of the anchor at the given position, or an empty string if no anchor exists at that point.

### QFont QAbstractTextDocumentLayout::defaultFont () const

Returns the default font to be used in the document layout.

### const QTextDocument * QAbstractTextDocumentLayout::document () const `[protected]`

Returns the text document that this layout is operating on.

### void QAbstractTextDocumentLayout::documentChange ( int from, int oldLength, int length ) `[pure virtual]`

This function is called whenever the contents of the document change. A change is an insertion of text, text removal, or the combination of both. The from argument defines the beginning of the change in the document. The oldLength argument specifies the length of the area that was modified before the actual change, and length is the length afterwards.

For example when simply inserting the text "Hello", oldLength would be 0 and length would equal 5 (the length of the string).

If for example 3 characters get removed, then oldLength would be equal to 3 while length would be 0, as before the change there were 3 characters and afterwards none.

Replacing text is the combination of removal and insertion. For example, if the text "Hello" gets replaced by "Hi", oldLength would be 5 and length would be 2.

### void QAbstractTextDocumentLayout::draw ( QPainter * painter, const PaintContext & context ) `[pure virtual]`

Draws the layout on the given painter with the given context.

### void QAbstractTextDocumentLayout::drawObject ( QPainter * painter, const QRectF & rect, QTextInlineObject object, const QTextFormat & format, QTextLayout::SelectionType selection ) `[virtual]`

### QTextCharFormat QAbstractTextDocumentLayout::format ( int position ) `[protected]`

Returns the character format that is applicable at the given position.

### QRect QAbstractTextDocumentLayout::frameBoundingRect ( QTextFrame * frame ) const `[virtual]`

Returns the bounding rectacle of frame .

### int QAbstractTextDocumentLayout::hitTest ( const QPoint & point, Qt::HitTestAccuracy accuracy ) const `[pure virtual]`

### void QAbstractTextDocumentLayout::layoutObject ( QTextInlineObject item, const QTextFormat & format ) `[virtual]`

Lays out the inline object item using the given text format. The base class implementation does nothing.

See also drawObject().

### int QAbstractTextDocumentLayout::numPages () const `[pure virtual]`

Returns the number of pages required by this layout; this depends in part on the pageSize().

### QSize QAbstractTextDocumentLayout::pageSize () const `[pure virtual]`

Returns the page size.

See also setPageSize() and numPages().

### void QAbstractTextDocumentLayout::setDefaultFont ( const QFont & font )

Sets the default font to use in the document layout.

### void QAbstractTextDocumentLayout::setPageSize ( const QSize & size ) `[pure virtual]`

Sets the page size.

See also pageSize() and numPages().

### void QAbstractTextDocumentLayout::setSize ( QTextInlineObject item, const QTextFormat & format ) `[virtual]`

Sets the size of the inline object item in accordance with the text format.

### QSize QAbstractTextDocumentLayout::sizeUsed () const `[virtual]`

Returns the size used for the document. The default implementation just calls pageSize(). For example, if your layout is similar to HTML then you may want to re-implement this function, and return the size your document actually used, as that will differ from the page size.

See also setPageSize() and pageSize().

### void QAbstractTextDocumentLayout::update ( const QRect & rect = QRect( 0, 0, 0x10000000, 0x10000000 ) ) `[signal]`

This signal is emitted when the rectangle rect has been updated.