Class: QgsLayoutItemGuiRegistry

Registry of available layout item GUI behavior.

QgsLayoutItemGuiRegistry is not usually directly created, but rather accessed through QgsGui.layoutItemGuiRegistry().

This acts as a companion to QgsLayoutItemRegistry, handling only the components related to the GUI behavior of layout items.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsLayoutItemGuiRegistry

Base classes

QObject

class qgis.gui.QgsLayoutItemGuiRegistry[source]

Bases: QObject

__init__(parent: QObject | None = None)

Creates a new empty item GUI registry.

QgsLayoutItemGuiRegistry is not usually directly created, but rather accessed through QgsGui.layoutItemGuiRegistry().

Parameters:

parent (Optional[QObject] = None)

addItemGroup(self, group: QgsLayoutItemGuiGroup) bool[source]

Registers a new item group with the registry. This must be done before calling addLayoutItemGuiMetadata() for any item types associated with the group.

Returns True if group was added, or False if group could not be added (e.g. due to duplicate id value).

See also

itemGroup()

Parameters:

group (QgsLayoutItemGuiGroup)

Return type:

bool

addLayoutItemGuiMetadata(self, metadata: QgsLayoutItemAbstractGuiMetadata | None) bool[source]

Registers the GUI metadata for a new layout item type. Takes ownership of the metadata instance.

Parameters:

metadata (Optional[QgsLayoutItemAbstractGuiMetadata])

Return type:

bool

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

Creates a new instance of a layout item given the item metadata metadataId, target layout.

Parameters:
  • metadataId (int)

  • layout (Optional[QgsLayout])

Return type:

Optional[QgsLayoutItem]

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

Creates a new instance of a layout item configuration widget for the specified item.

Parameters:

item (Optional[QgsLayoutItem])

Return type:

Optional[QgsLayoutItemBaseWidget]

signal groupRemoved[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

itemGroup(self, id: str | None) QgsLayoutItemGuiGroup

Returns a reference to the item group with matching id.

See also

addItemGroup()

Parameters:

id (Optional[str])

Return type:

QgsLayoutItemGuiGroup

itemMetadata(self, metadataId: int) QgsLayoutItemAbstractGuiMetadata | None[source]

Returns the metadata for the specified item metadataId. Returns None if a corresponding metadataId was not found in the registry.

Parameters:

metadataId (int)

Return type:

Optional[QgsLayoutItemAbstractGuiMetadata]

itemMetadataIds(self) List[int]

Returns a list of available item metadata ids handled by the registry.

Return type:

List[int]

metadataIdForItemType(self, type: int) int[source]

Returns the GUI item metadata ID which corresponds to the specified layout item type.

In the case that multiple GUI metadata classes exist for a single layout item type then only the first encountered GUI metadata ID will be returned.

Returns -1 if no matching metadata is found in the GUI registry.

Added in version 3.18.

Parameters:

type (int)

Return type:

int

newItemAddedToLayout(self, metadataId: int, item: QgsLayoutItem | None, properties: Dict[str, Any] = {})[source]

Called when a newly created item of the associated metadata metadataId 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.

Since QGIS 3.18 the optional properties argument can be used to pass custom properties to the QgsLayoutItemGuiMetadata.newItemAddedToLayout() function.

Parameters:
  • metadataId (int)

  • item (Optional[QgsLayoutItem])

  • properties (Dict[str, Any] = {})

removeItemGroup(self, id: str | None) bool[source]

Unregisters an item group from the registry.

This must be done after calling removeLayoutItemGuiMetadata() for every item types associated with the group.

Added in version 4.0.

Parameters:

id (Optional[str])

Return type:

bool

removeLayoutItemGuiMetadata(self, type: int) bool[source]

Unregisters the GUI metadata for a layout item type.

Added in version 4.0.

removeLayoutItemGuiMetadata(self, metadata: Optional[QgsLayoutItemAbstractGuiMetadata]) -> bool Unregisters the GUI metadata for a layout item type.

The metadata object will be deleted and should not be used after this call.

Added in version 4.0.

Parameters:

type (int)

Return type:

bool

signal typeAdded[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

signal typeRemoved[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.