Class: QgsLayoutItemAbstractGuiMetadata

Stores GUI metadata about one layout item class.

This is a companion to QgsLayoutItemAbstractMetadata, storing only the components related to the GUI behavior of a layout item.

Note

In C++ you can use QgsLayoutItemGuiMetadata convenience class.

Methods

flags

Returns item flags.

groupId

Returns the item group ID, if set.

isNodeBased

Returns True if the associated item is a node based item.

type

Returns the unique item type code for the layout item class.

visibleName

Returns a translated, user visible name identifying the corresponding layout item.

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsLayoutItemAbstractGuiMetadata. See the FAQ for more details.

createItem

Creates an instance of the corresponding item type.

createItemWidget

Creates a configuration widget for an item of this type.

createNodeRubberBand

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

createRubberBand

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

creationIcon

Returns an icon representing creation of the layout item type.

handleDoubleClick

Called when a layout item is double-clicked.

newItemAddedToLayout

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

Attributes

FlagNoCreationTools

class qgis.gui.QgsLayoutItemAbstractGuiMetadata[source]

Bases: object

__init__(type: int, visibleName: str | None, groupId: str | None = '', isNodeBased: bool = False, flags: QgsLayoutItemAbstractGuiMetadata.Flags | QgsLayoutItemAbstractGuiMetadata.Flag = QgsLayoutItemAbstractGuiMetadata.Flags())

Constructor for QgsLayoutItemAbstractGuiMetadata with the specified class type.

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.

Parameters:
__init__(a0: QgsLayoutItemAbstractGuiMetadata)
Parameters:

a0 (QgsLayoutItemAbstractGuiMetadata)

class Flag

Bases: int

FlagNoCreationTools = 2
class Flags
class Flags(f: QgsLayoutItemAbstractGuiMetadata.Flags | QgsLayoutItemAbstractGuiMetadata.Flag)
class Flags(a0: QgsLayoutItemAbstractGuiMetadata.Flags)

Bases: object

virtual createItem(self, layout: QgsLayout | None) QgsLayoutItem | None[source]

Creates an instance of the corresponding item type.

Parameters:

layout (Optional[QgsLayout])

Return type:

Optional[QgsLayoutItem]

virtual createItemWidget(self, item: QgsLayoutItem | None) QgsLayoutItemBaseWidget | None[source]

Creates a configuration widget for an item of this type. Can return None if no configuration GUI is required.

Parameters:

item (Optional[QgsLayoutItem])

Return type:

Optional[QgsLayoutItemBaseWidget]

virtual createNodeRubberBand(self, view: QgsLayoutView | None) QGraphicsItem | None[source]

Creates a rubber band for use when creating layout node based items of this type. Can return None if no rubber band should be created. The default behavior is to return None.

Parameters:

view (Optional[QgsLayoutView])

Return type:

Optional[QGraphicsItem]

virtual createRubberBand(self, view: QgsLayoutView | None) QgsLayoutViewRubberBand | None[source]

Creates a rubber band for use when creating layout items of this type. Can return None if no rubber band should be created. The default behavior is to create a rectangular rubber band.

Parameters:

view (Optional[QgsLayoutView])

Return type:

Optional[QgsLayoutViewRubberBand]

virtual creationIcon(self) QIcon[source]

Returns an icon representing creation of the layout item type.

Return type:

QIcon

flags(self) QgsLayoutItemAbstractGuiMetadata.Flags[source]

Returns item flags.

Return type:

QgsLayoutItemAbstractGuiMetadata.Flags

groupId(self) str[source]

Returns the item group ID, if set.

Return type:

str

virtual handleDoubleClick(self, item: QgsLayoutItem | None, action: Qgis.MouseHandlesAction)[source]

Called when a layout item is double-clicked. The action parameter is used to specify which mouse handle, if any, was clicked If no mouse handle is selected, Qgis.MouseHandlesAction.NoAction is used

Added in version 3.42.

Parameters:
isNodeBased(self) bool[source]

Returns True if the associated item is a node based item.

Return type:

bool

virtual newItemAddedToLayout(self, item: QgsLayoutItem | None)[source]

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.

Parameters:

item (Optional[QgsLayoutItem])

type(self) int[source]

Returns the unique item type code for the layout item class.

Return type:

int

visibleName(self) str[source]

Returns a translated, user visible name identifying the corresponding layout item.

Return type:

str