#[repr(C)]
pub struct QTextObjectInterface { /* private fields */ }
Expand description

The QTextObjectInterface class allows drawing of custom text objects in QTextDocuments.

C++ class: QTextObjectInterface.

C++ documentation:

The QTextObjectInterface class allows drawing of custom text objects in QTextDocuments.

A text object describes the structure of one or more elements in a text document; for instance, images imported from HTML are implemented using text objects. A text object knows how to lay out and draw its elements when a document is being rendered.

Qt allows custom text objects to be inserted into a document by registering a custom object type with QTextCharFormat. A QTextObjectInterface must also be implemented for this type and be registered with the QAbstractTextDocumentLayout of the document. When the object type is encountered while rendering a QTextDocument, the intrinsicSize() and drawObject() functions of the interface are called.

The following list explains the required steps of inserting a custom text object into a document:

A class implementing a text object needs to inherit both QObject and QTextObjectInterface. QObject must be the first class inherited. For instance:

class SvgTextObject : public QObject, public QTextObjectInterface { Q_OBJECT Q_INTERFACES(QTextObjectInterface)

The data of a text object is usually stored in the QTextCharFormat using QTextCharFormat::setProperty(), and then retrieved with QTextCharFormat::property().

Warning: Copy and Paste operations ignore custom text objects.

Implementations§

source§

impl QTextObjectInterface

source

pub unsafe fn copy_from( &self, other: impl CastInto<Ref<QTextObjectInterface>> ) -> Ref<QTextObjectInterface>

The QTextObjectInterface class allows drawing of custom text objects in QTextDocuments.

Calls C++ function: QTextObjectInterface& QTextObjectInterface::operator=(const QTextObjectInterface& other).

C++ documentation:

The QTextObjectInterface class allows drawing of custom text objects in QTextDocuments.

A text object describes the structure of one or more elements in a text document; for instance, images imported from HTML are implemented using text objects. A text object knows how to lay out and draw its elements when a document is being rendered.

Qt allows custom text objects to be inserted into a document by registering a custom object type with QTextCharFormat. A QTextObjectInterface must also be implemented for this type and be registered with the QAbstractTextDocumentLayout of the document. When the object type is encountered while rendering a QTextDocument, the intrinsicSize() and drawObject() functions of the interface are called.

The following list explains the required steps of inserting a custom text object into a document:

A class implementing a text object needs to inherit both QObject and QTextObjectInterface. QObject must be the first class inherited. For instance:

class SvgTextObject : public QObject, public QTextObjectInterface { Q_OBJECT Q_INTERFACES(QTextObjectInterface)

The data of a text object is usually stored in the QTextCharFormat using QTextCharFormat::setProperty(), and then retrieved with QTextCharFormat::property().

Warning: Copy and Paste operations ignore custom text objects.

source

pub unsafe fn draw_object( &self, painter: impl CastInto<Ptr<QPainter>>, rect: impl CastInto<Ref<QRectF>>, doc: impl CastInto<Ptr<QTextDocument>>, pos_in_document: c_int, format: impl CastInto<Ref<QTextFormat>> )

Draws this text object using the specified painter.

Calls C++ function: pure virtual void QTextObjectInterface::drawObject(QPainter* painter, const QRectF& rect, QTextDocument* doc, int posInDocument, const QTextFormat& format).

C++ documentation:

Draws this text object using the specified painter.

The size of the rectangle, rect, to draw in is the size previously calculated by intrinsicSize(). The rectangles position is relative to the painter.

You also get the document (doc) and the position (posInDocument) of the format in that document.

See also intrinsicSize().

source

pub unsafe fn intrinsic_size( &self, doc: impl CastInto<Ptr<QTextDocument>>, pos_in_document: c_int, format: impl CastInto<Ref<QTextFormat>> ) -> CppBox<QSizeF>

The intrinsicSize() function returns the size of the text object represented by format in the given document (doc) at the given position (posInDocument).

Calls C++ function: pure virtual QSizeF QTextObjectInterface::intrinsicSize(QTextDocument* doc, int posInDocument, const QTextFormat& format).

C++ documentation:

The intrinsicSize() function returns the size of the text object represented by format in the given document (doc) at the given position (posInDocument).

The size calculated will be used for subsequent calls to drawObject() for this format.

See also drawObject().

Trait Implementations§

source§

impl CppDeletable for QTextObjectInterface

source§

unsafe fn delete(&self)

Destroys this QTextObjectInterface.

Calls C++ function: virtual [destructor] void QTextObjectInterface::~QTextObjectInterface().

C++ documentation:

Destroys this QTextObjectInterface.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.