QgsLayoutItemRegistry class

Registry of available layout item types.

QgsLayoutItemRegistry is not usually directly created, but rather accessed through QgsApplication::layoutItemRegistry().

A companion class, QgsLayoutItemGuiRegistry, handles the GUI behavior of layout items.

Public types

enum ItemType { LayoutItem = QGraphicsItem::UserType + 100, LayoutGroup, LayoutPage, LayoutMap, LayoutPicture, LayoutLabel, LayoutLegend, LayoutShape, LayoutPolygon, LayoutPolyline, LayoutScaleBar, LayoutFrame, LayoutHtml, LayoutAttributeTable, LayoutTextTable, Layout3DMap, PluginItem = LayoutTextTable + 10000 }
Item types.

Constructors, destructors, conversion operators

QgsLayoutItemRegistry(QObject* parent = nullptr)
Creates a new empty item registry.
QgsLayoutItemRegistry(const QgsLayoutItemRegistry& rh) deleted
QgsLayoutItemRegistry cannot be copied.

Public functions

auto addLayoutItemType(QgsLayoutItemAbstractMetadata* metadata) -> bool
Registers a new layout item type.
auto addLayoutMultiFrameType(QgsLayoutMultiFrameAbstractMetadata* metadata) -> bool
Registers a new layout multiframe type.
auto createItem(int type, QgsLayout* layout) const -> QgsLayoutItem*
Creates a new instance of a layout item given the item type, and target layout.
auto createMultiFrame(int type, QgsLayout* layout) const -> QgsLayoutMultiFrame*
Creates a new instance of a layout multiframe given the multiframe type, and target layout.
auto itemMetadata(int type) const -> QgsLayoutItemAbstractMetadata*
Returns the metadata for the specified item type.
auto itemTypes() const -> QMap<int, QString>
Returns a map of available item types to translated name.
auto multiFrameMetadata(int type) const -> QgsLayoutMultiFrameAbstractMetadata*
Returns the metadata for the specified multiframe type.
auto operator=(const QgsLayoutItemRegistry& rh) -> QgsLayoutItemRegistry& deleted
QgsLayoutItemRegistry cannot be copied.
auto populate() -> bool
Populates the registry with standard item types.
void resolvePaths(int type, QVariantMap& properties, const QgsPathResolver& pathResolver, bool saving) const
Resolve paths in properties of a particular symbol layer.

Signals

void multiFrameTypeAdded(int type, const QString& name)
Emitted whenever a new multiframe type is added to the registry, with the specified type and visible name.
void typeAdded(int type, const QString& name)
Emitted whenever a new item type is added to the registry, with the specified type and visible name.

Enum documentation

enum QgsLayoutItemRegistry::ItemType

Item types.

Enumerators
LayoutItem

Base class for items.

LayoutGroup

Grouped item.

LayoutPage

Page items.

LayoutMap

Map item.

LayoutPicture

Picture item.

LayoutLabel

Label item.

LayoutLegend

Legend item.

LayoutShape

Shape item.

LayoutPolygon

Polygon shape item.

LayoutPolyline

Polyline shape item.

LayoutScaleBar

Scale bar item.

LayoutFrame

Frame item, part of a QgsLayoutMultiFrame object.

LayoutHtml

Html multiframe item.

LayoutAttributeTable

Attribute table.

LayoutTextTable

Preset text table.

Layout3DMap

3D map item

PluginItem

Starting point for plugin item types.

Function documentation

QgsLayoutItemRegistry::QgsLayoutItemRegistry(QObject* parent = nullptr)

Creates a new empty item registry.

QgsLayoutItemRegistry is not usually directly created, but rather accessed through QgsApplication::layoutItemRegistry().

bool QgsLayoutItemRegistry::addLayoutItemType(QgsLayoutItemAbstractMetadata* metadata)

Registers a new layout item type.

Takes ownership of the metadata instance.

bool QgsLayoutItemRegistry::addLayoutMultiFrameType(QgsLayoutMultiFrameAbstractMetadata* metadata)

Registers a new layout multiframe type.

Takes ownership of the metadata instance.

QgsLayoutItem* QgsLayoutItemRegistry::createItem(int type, QgsLayout* layout) const

Creates a new instance of a layout item given the item type, and target layout.

QgsLayoutMultiFrame* QgsLayoutItemRegistry::createMultiFrame(int type, QgsLayout* layout) const

Creates a new instance of a layout multiframe given the multiframe type, and target layout.

QgsLayoutItemAbstractMetadata* QgsLayoutItemRegistry::itemMetadata(int type) const

Returns the metadata for the specified item type.

Returns nullptr if a corresponding type was not found in the registry.

QgsLayoutMultiFrameAbstractMetadata* QgsLayoutItemRegistry::multiFrameMetadata(int type) const

Returns the metadata for the specified multiframe type.

Returns nullptr if a corresponding type was not found in the registry.

bool QgsLayoutItemRegistry::populate()

Populates the registry with standard item types.

If called on a non-empty registry then this will have no effect and will return false.

void QgsLayoutItemRegistry::resolvePaths(int type, QVariantMap& properties, const QgsPathResolver& pathResolver, bool saving) const

Resolve paths in properties of a particular symbol layer.

This normally means converting relative paths to absolute paths when loading and converting absolute paths to relative paths when saving.