QgsLayoutSerializableObject class

An interface for layout objects which can be stored and read from DOM elements.

Base classes

class QgsLayoutUndoObjectInterface
Interface for layout objects which support undo/redo commands.

Derived classes

class QgsLayoutAtlas
Class used to render QgsLayout as an atlas, by iterating over the features from an associated vector layer.
class QgsLayoutGridSettings
Contains settings relating to the appearance, spacing and offset for layout grids.
class QgsLayoutGuideCollection
Stores and manages the snap guides used by a layout.
class QgsLayoutPageCollection
A manager for a collection of pages in a layout.
class QgsLayoutSnapper
Manages snapping grids and preset snap lines in a layout, and handles snapping points to the nearest grid coordinate/snap line when possible.

Public functions

auto createCommand(const QString& text, int id, QUndoCommand* parent = nullptr) -> QgsAbstractLayoutUndoCommand* override
Creates a new layout undo command with the specified text and parent.
auto layout() -> QgsLayout* pure virtual
Returns the layout the object belongs to.
auto readXml(const QDomElement& element, const QDomDocument& document, const QgsReadWriteContext& context) -> bool pure virtual
Sets the objects's state from a DOM element.
auto stringType() const -> QString pure virtual
Returns the object type as a string.
auto writeXml(QDomElement& parentElement, QDomDocument& document, const QgsReadWriteContext& context) const -> bool pure virtual
Stores the objects's state in a DOM element.

Function documentation

QgsAbstractLayoutUndoCommand* QgsLayoutSerializableObject::createCommand(const QString& text, int id, QUndoCommand* parent = nullptr) override

Creates a new layout undo command with the specified text and parent.

The id argument can be used to specify an id number for the source event - this is used to determine whether QUndoCommand command compression can apply to the command.

bool QgsLayoutSerializableObject::readXml(const QDomElement& element, const QDomDocument& document, const QgsReadWriteContext& context) pure virtual

Sets the objects's state from a DOM element.

element is the DOM node corresponding to the object.

QString QgsLayoutSerializableObject::stringType() const pure virtual

Returns the object type as a string.

This string must be a unique, single word, character only representation of the item type, eg "LayoutScaleBar"

bool QgsLayoutSerializableObject::writeXml(QDomElement& parentElement, QDomDocument& document, const QgsReadWriteContext& context) const pure virtual

Stores the objects's state in a DOM element.

The parentElement should refer to the parent layout's DOM element.