QAbstractTextDocumentLayout

继承者: QPlainTextDocumentLayout

概要

函数

虚函数

信号

详细描述

PySide.QtGui.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 images, 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 PySide.QtGui.QAbstractTextDocumentLayout to provide custom layout behavior for your text documents.

An instance of the PySide.QtGui.QAbstractTextDocumentLayout subclass can be installed on a PySide.QtGui.QTextDocument object with the PySide.QtGui.QTextDocument.setDocumentLayout() 函数。

You can insert custom objects into a PySide.QtGui.QTextDocument ; see the PySide.QtGui.QTextObjectInterface 类描述了解细节。

class PySide.QtGui. QAbstractTextDocumentLayout ( doc )
参数: doc PySide.QtGui.QTextDocument

Creates a new text document layout for the given document .

PySide.QtGui.QAbstractTextDocumentLayout. anchorAt ( pos )
参数: pos PySide.QtCore.QPointF
返回类型: unicode

Returns the reference of the anchor the given position ,或空字符串若该点不存在锚点。

PySide.QtGui.QAbstractTextDocumentLayout. blockBoundingRect ( block )
参数: block PySide.QtGui.QTextBlock
返回类型: PySide.QtCore.QRectF

Returns the bounding rectangle of block .

PySide.QtGui.QAbstractTextDocumentLayout. document ( )
返回类型: PySide.QtGui.QTextDocument

Returns the text document that this layout is operating on.

PySide.QtGui.QAbstractTextDocumentLayout. documentChanged ( from , charsRemoved , charsAdded )
参数:
  • from PySide.QtCore.int
  • charsRemoved PySide.QtCore.int
  • charsAdded PySide.QtCore.int

This function is called whenever the contents of the document change. A change occurs when text is inserted, removed, or a combination of these two. The change is specified by position , charsRemoved ,和 charsAdded corresponding to the starting character position of the change, the number of characters removed from the document, and the number of characters added.

For example, when inserting the text “Hello” into an empty document, charsRemoved would be 0 and charsAdded would be 5 (the length of the string).

Replacing text is a combination of removing and inserting. For example, if the text “Hello” gets replaced by “Hi”, charsRemoved would be 5 and charsAdded would be 2.

For subclasses of PySide.QtGui.QAbstractTextDocumentLayout , this is the central function where a large portion of the work to lay out and position document contents is done.

For example, in a subclass that only arranges blocks of text, an implementation of this function would have to do the following:

PySide.QtGui.QAbstractTextDocumentLayout. documentSize ( )
返回类型: PySide.QtCore.QSizeF

Returns the total size of the document's layout.

This information can be used by display widgets to update their scroll bars correctly.

PySide.QtGui.QAbstractTextDocumentLayout. documentSizeChanged ( newSize )
参数: newSize PySide.QtCore.QSizeF
PySide.QtGui.QAbstractTextDocumentLayout. draw ( painter , context )
参数:

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

PySide.QtGui.QAbstractTextDocumentLayout. drawInlineObject ( painter , rect , object , posInDocument , format )
参数:

This function is called to draw the inline object, object ,采用给定 painter within the rectangle specified by rect using the specified text format .

posInDocument specifies the position of the object within the document.

The default implementation calls drawObject() on the object handlers. This function is called only within Qt. Subclasses can reimplement this function to customize the drawing of inline objects.

PySide.QtGui.QAbstractTextDocumentLayout. format ( pos )
参数: pos PySide.QtCore.int
返回类型: PySide.QtGui.QTextCharFormat

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

PySide.QtGui.QAbstractTextDocumentLayout. formatIndex ( pos )
参数: pos PySide.QtCore.int
返回类型: PySide.QtCore.int

Returns the index of the format at position pos .

PySide.QtGui.QAbstractTextDocumentLayout. frameBoundingRect ( frame )
参数: frame PySide.QtGui.QTextFrame
返回类型: PySide.QtCore.QRectF

Returns the bounding rectangle of frame .

PySide.QtGui.QAbstractTextDocumentLayout. handlerForObject ( objectType )
参数: objectType PySide.QtCore.int
返回类型: PySide.QtGui.QTextObjectInterface

Returns a handler for objects of the given objectType .

PySide.QtGui.QAbstractTextDocumentLayout. hitTest ( point , accuracy )
参数:
返回类型:

PySide.QtCore.int

PySide.QtGui.QAbstractTextDocumentLayout. pageCount ( )
返回类型: PySide.QtCore.int

Returns the number of pages contained in the layout.

PySide.QtGui.QAbstractTextDocumentLayout. pageCountChanged ( newPages )
参数: newPages PySide.QtCore.int
PySide.QtGui.QAbstractTextDocumentLayout. paintDevice ( )
返回类型: PySide.QtGui.QPaintDevice

Returns the paint device used to render the document's layout.

PySide.QtGui.QAbstractTextDocumentLayout. positionInlineObject ( item , posInDocument , format )
参数:

Lays out the inline object item using the given text format .

posInDocument specifies the position of the object within the document.

The default implementation does nothing. This function is called only within Qt. Subclasses can reimplement this function to customize the position of inline objects.

PySide.QtGui.QAbstractTextDocumentLayout. registerHandler ( objectType , component )
参数:

Registers the given component as a handler for items of the given objectType .

注意

PySide.QtGui.QAbstractTextDocumentLayout.registerHandler() has to be called once for each object type. This means that there is only one handler for multiple replacement characters of the same object type.

PySide.QtGui.QAbstractTextDocumentLayout. resizeInlineObject ( item , posInDocument , format )
参数:

Sets the size of the inline object item corresponding to the text format .

posInDocument specifies the position of the object within the document.

The default implementation resizes the item to the size returned by the object handler's intrinsicSize() function. This function is called only within Qt. Subclasses can reimplement this function to customize the resizing of inline objects.

PySide.QtGui.QAbstractTextDocumentLayout. setPaintDevice ( device )
参数: device PySide.QtGui.QPaintDevice

Sets the paint device used for rendering the document's layout to the given device .

PySide.QtGui.QAbstractTextDocumentLayout. update ( [ arg__1=QRectF(0. , 0. , 1000000000. , 1000000000.) ] )
参数: arg__1 PySide.QtCore.QRectF
PySide.QtGui.QAbstractTextDocumentLayout. updateBlock ( block )
参数: block PySide.QtGui.QTextBlock