QgsLayoutViewToolAddItem class

Layout view tool for adding items to a layout.

Base classes

class QgsLayoutViewTool
Abstract base class for all layout view tools.

Constructors, destructors, conversion operators

QgsLayoutViewToolAddItem(QgsLayoutView* view)
Constructs a QgsLayoutViewToolAddItem for the given layout view.

Public functions

void deactivate() override
Called when tool is deactivated.
auto itemMetadataId() const -> int
Returns the item metadata id for items created by the tool.
void layoutMoveEvent(QgsLayoutViewMouseEvent* event) override
Mouse move event for overriding.
void layoutPressEvent(QgsLayoutViewMouseEvent* event) override
Mouse press event for overriding.
void layoutReleaseEvent(QgsLayoutViewMouseEvent* event) override
Mouse release event for overriding.
void setItemMetadataId(int metadataId)
Sets the item metadata metadataId for items created by the tool.

Signals

void createdItem()
Emitted when an item has been created using the tool.

Function documentation

void QgsLayoutViewToolAddItem::deactivate() override

Called when tool is deactivated.

Overridden implementations must take care to call the base class implementation.

int QgsLayoutViewToolAddItem::itemMetadataId() const

Returns the item metadata id for items created by the tool.

void QgsLayoutViewToolAddItem::layoutMoveEvent(QgsLayoutViewMouseEvent* event) override

Mouse move event for overriding.

Default implementation does nothing.

void QgsLayoutViewToolAddItem::layoutPressEvent(QgsLayoutViewMouseEvent* event) override

Mouse press event for overriding.

Default implementation does nothing. Note that subclasses must ensure that they correctly handle cases when a layoutPressEvent is called without a corresponding layoutReleaseEvent (e.g. due to tool being changed mid way through a press-release operation).

void QgsLayoutViewToolAddItem::layoutReleaseEvent(QgsLayoutViewMouseEvent* event) override

Mouse release event for overriding.

Default implementation does nothing. Note that subclasses must ensure that they correctly handle cases when a layoutPressEvent is called without a corresponding layoutReleaseEvent (e.g. due to tool being changed mid way through a press-release operation).

void QgsLayoutViewToolAddItem::setItemMetadataId(int metadataId)

Sets the item metadata metadataId for items created by the tool.

The metadataId associates the current tool behavior with a metadata entry from QgsLayoutItemGuiRegistry.