QgsLayoutItemGuiMetadata class

Convenience metadata class that uses static functions to handle layout item GUI behavior.

Base classes

class QgsLayoutItemAbstractGuiMetadata
Stores GUI metadata about one layout item class.

Constructors, destructors, conversion operators

QgsLayoutItemGuiMetadata(int type, const QString& visibleName, const QIcon& creationIcon, const QgsLayoutItemWidgetFunc& pfWidget = nullptr, const QgsLayoutItemRubberBandFunc& pfRubberBand = nullptr, const QString& groupId = QString(), bool isNodeBased = false, QgsLayoutItemAbstractGuiMetadata::Flags flags = nullptr, const QgsLayoutItemCreateFunc& pfCreateFunc = nullptr)
Constructor for QgsLayoutItemGuiMetadata with the specified class type and creationIcon, and function pointers for the various configuration widget creation functions.

Public functions

auto createItem(QgsLayout* layout) -> QgsLayoutItem* override
Creates an instance of the corresponding item type.
auto createItemWidget(QgsLayoutItem* item) -> QgsLayoutItemBaseWidget* override
Creates a configuration widget for an item of this type.
auto createNodeRubberBand(QgsLayoutView* view) -> QAbstractGraphicsShapeItem* override
Creates a rubber band for use when creating layout node based items of this type.
auto createRubberBand(QgsLayoutView* view) -> QgsLayoutViewRubberBand* override
Creates a rubber band for use when creating layout items of this type.
auto creationIcon() const -> QIcon override
Returns an icon representing creation of the layout item type.
auto itemAddToLayoutFunction() const -> QgsLayoutItemAddedToLayoutFunc
Returns the classes' item added to layout function.
auto itemCreationFunction() const -> QgsLayoutItemCreateFunc
Returns the classes' item creation function.
void newItemAddedToLayout(QgsLayoutItem* item) override
Called when a newly created item of the associated type has been added to a layout.
auto nodeRubberBandCreationFunction() const -> QgsLayoutNodeItemRubberBandFunc
Returns the classes' node based rubber band creation function.
auto rubberBandCreationFunction() const -> QgsLayoutItemRubberBandFunc
Returns the classes' rubber band creation function.
void setItemAddedToLayoutFunction(const QgsLayoutItemAddedToLayoutFunc& function)
Sets the classes' item creation function.
void setItemCreationFunction(const QgsLayoutItemCreateFunc& function)
Sets the classes' item creation function.
void setNodeRubberBandCreationFunction(const QgsLayoutNodeItemRubberBandFunc& function)
Sets the classes' node based rubber band creation function.
void setRubberBandCreationFunction(const QgsLayoutItemRubberBandFunc& function)
Sets the classes' rubber band creation function.
void setWidgetFunction(const QgsLayoutItemWidgetFunc& function)
Sets the classes' configuration widget creation function.
auto widgetFunction() const -> QgsLayoutItemWidgetFunc
Returns the classes' configuration widget creation function.

Function documentation

QgsLayoutItemGuiMetadata::QgsLayoutItemGuiMetadata(int type, const QString& visibleName, const QIcon& creationIcon, const QgsLayoutItemWidgetFunc& pfWidget = nullptr, const QgsLayoutItemRubberBandFunc& pfRubberBand = nullptr, const QString& groupId = QString(), bool isNodeBased = false, QgsLayoutItemAbstractGuiMetadata::Flags flags = nullptr, const QgsLayoutItemCreateFunc& pfCreateFunc = nullptr)

Constructor for QgsLayoutItemGuiMetadata with the specified class type and creationIcon, and function pointers for the various configuration widget creation functions.

visibleName should be set to a translated, user visible name identifying the corresponding layout item.

An optional groupId can be set, which allows grouping of related layout item classes. See QgsLayoutItemGuiMetadata for details.

If isNodeBased is true, then the corresponding item is a node based item.

QgsLayoutItemBaseWidget* QgsLayoutItemGuiMetadata::createItemWidget(QgsLayoutItem* item) override

Creates a configuration widget for an item of this type.

Can return nullptr if no configuration GUI is required.

QAbstractGraphicsShapeItem* QgsLayoutItemGuiMetadata::createNodeRubberBand(QgsLayoutView* view) override

Creates a rubber band for use when creating layout node based items of this type.

Can return nullptr if no rubber band should be created. The default behavior is to return nullptr.

QgsLayoutViewRubberBand* QgsLayoutItemGuiMetadata::createRubberBand(QgsLayoutView* view) override

Creates a rubber band for use when creating layout items of this type.

Can return nullptr if no rubber band should be created. The default behavior is to create a rectangular rubber band.

QgsLayoutItemAddedToLayoutFunc QgsLayoutItemGuiMetadata::itemAddToLayoutFunction() const

Returns the classes' item added to layout function.

QgsLayoutItemCreateFunc QgsLayoutItemGuiMetadata::itemCreationFunction() const

Returns the classes' item creation function.

void QgsLayoutItemGuiMetadata::newItemAddedToLayout(QgsLayoutItem* item) override

Called when a newly created item of the associated type has been added to a layout.

This is only called for additions which result from GUI operations - i.e. it is not called for items added from templates.

QgsLayoutNodeItemRubberBandFunc QgsLayoutItemGuiMetadata::nodeRubberBandCreationFunction() const

Returns the classes' node based rubber band creation function.

QgsLayoutItemRubberBandFunc QgsLayoutItemGuiMetadata::rubberBandCreationFunction() const

Returns the classes' rubber band creation function.

void QgsLayoutItemGuiMetadata::setItemAddedToLayoutFunction(const QgsLayoutItemAddedToLayoutFunc& function)

Sets the classes' item creation function.

void QgsLayoutItemGuiMetadata::setItemCreationFunction(const QgsLayoutItemCreateFunc& function)

Sets the classes' item creation function.

void QgsLayoutItemGuiMetadata::setNodeRubberBandCreationFunction(const QgsLayoutNodeItemRubberBandFunc& function)

Sets the classes' node based rubber band creation function.

void QgsLayoutItemGuiMetadata::setRubberBandCreationFunction(const QgsLayoutItemRubberBandFunc& function)

Sets the classes' rubber band creation function.

void QgsLayoutItemGuiMetadata::setWidgetFunction(const QgsLayoutItemWidgetFunc& function)

Sets the classes' configuration widget creation function.

QgsLayoutItemWidgetFunc QgsLayoutItemGuiMetadata::widgetFunction() const

Returns the classes' configuration widget creation function.