QAbstractTextDocumentLayout Class
The QAbstractTextDocumentLayout class is an abstract base class used to implement custom layouts for QTextDocuments. More...
Header: | #include <QAbstractTextDocumentLayout> |
qmake: | QT += gui |
Inherits: | QObject |
Note: All functions in this class are reentrant.
Public Types
Public Functions
QAbstractTextDocumentLayout(QTextDocument *document) | |
QTextDocument * | document() const |
QTextFormat | formatAt(const QPointF &pos) const |
QTextObjectInterface * | handlerForObject(int objectType) const |
QString | imageAt(const QPointF &pos) const |
QPaintDevice * | paintDevice() const |
void | registerHandler(int objectType, QObject *component) |
void | setPaintDevice(QPaintDevice *device) |
void | unregisterHandler(int objectType, QObject *component = nullptr) |
- 16 public functions inherited from QObject
Protected Functions
virtual void | positionInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format) |
virtual void | resizeInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format) |
- 8 protected functions inherited from QObject
Related Non-Members
typedef | QObjectList |
Macros
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
Q_CLASSINFO(Name, Value) | |
Q_DISABLE_COPY(Class) | |
Q_DISABLE_COPY_MOVE(Class) | |
Q_DISABLE_MOVE(Class) | |
Q_EMIT | |
Q_ENUM(...) | |
Q_ENUM_NS(...) | |
Q_FLAG(...) | |
Q_FLAG_NS(...) | |
Q_GADGET | |
Q_INTERFACES(...) | |
Q_INVOKABLE | |
Q_NAMESPACE | |
Q_OBJECT | |
Q_PROPERTY(...) | |
Q_REVISION | |
Q_SET_OBJECT_NAME(Object) | |
Q_SIGNAL | |
Q_SIGNALS | |
Q_SLOT | |
Q_SLOTS |
Additional Inherited Members
- 1 property inherited from QObject
- 1 public slot inherited from QObject
- 1 signal inherited from QObject
- 5 static public members inherited from QObject
Detailed Description
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 QAbstractTextDocumentLayout to provide custom layout behavior for your text documents.
An instance of the QAbstractTextDocumentLayout subclass can be installed on a QTextDocument object with the setDocumentLayout() function.
You can insert custom objects into a QTextDocument; see the QTextObjectInterface class description for details.
See also QTextObjectInterface.
Member Function Documentation
QAbstractTextDocumentLayout::QAbstractTextDocumentLayout(QTextDocument *document)
Creates a new text document layout for the given document.
QTextDocument *QAbstractTextDocumentLayout::document() const
Returns the text document that this layout is operating on.
QTextFormat QAbstractTextDocumentLayout::formatAt(const QPointF &pos) const
Returns the text format at the given position pos.
This function was introduced in Qt 5.8.
QTextObjectInterface *QAbstractTextDocumentLayout::handlerForObject(int objectType) const
Returns a handler for objects of the given objectType.
QString QAbstractTextDocumentLayout::imageAt(const QPointF &pos) const
Returns the source of the image at the given position pos, or an empty string if no image exists at that point.
This function was introduced in Qt 5.8.
QPaintDevice *QAbstractTextDocumentLayout::paintDevice() const
Returns the paint device used to render the document's layout.
See also setPaintDevice().
[virtual protected]
void QAbstractTextDocumentLayout::positionInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &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.
See also drawInlineObject().
void QAbstractTextDocumentLayout::registerHandler(int objectType, QObject *component)
Registers the given component as a handler for items of the given objectType.
Note: 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.
The text document layout does not take ownership of component
.
[virtual protected]
void QAbstractTextDocumentLayout::resizeInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &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.
void QAbstractTextDocumentLayout::setPaintDevice(QPaintDevice *device)
Sets the paint device used for rendering the document's layout to the given device.
See also paintDevice().
void QAbstractTextDocumentLayout::unregisterHandler(int objectType, QObject *component = nullptr)
Unregisters the given component as a handler for items of the given objectType, or any handler if the component is not specified.
This function was introduced in Qt 5.2.