Class: QgsLayoutModel

A model for items attached to a layout.

The model also maintains the z-order for the layout, and must be notified whenever item stacking changes.

Internally, QgsLayoutModel maintains two lists. One contains a complete list of all items for the layout, ordered by their position within the z-order stack.

The second list contains only items which are currently displayed in the layout’s scene. It is used as a cache of the last known stacking order, so that the model can compare the current stacking of items in the layout to the last known state, and emit the corresponding signals as required.

Class Hierarchy

Inheritance diagram of qgis.core.QgsLayoutModel

Base classes

QAbstractItemModel

QObject

Methods

indexForItem

Returns the QModelIndex corresponding to a QgsLayoutItem item and column, if possible.

itemFromIndex

Returns the QgsLayoutItem corresponding to a QModelIndex index, if possible.

Attributes

ItemId

LockStatus

Visibility

class qgis.core.QgsLayoutModel[source]

Bases: QAbstractItemModel

__init__(layout: QgsLayout | None, parent: QObject | None = None)

Constructor for a QgsLayoutModel attached to the specified layout.

Parameters:
  • layout (Optional[QgsLayout])

  • parent (Optional[QObject] = None)

class Columns

Bases: int

ItemId = 2
LockStatus = 1
Visibility = 0
indexForItem(self, item: QgsLayoutItem | None, column: int = 0) QModelIndex[source]

Returns the QModelIndex corresponding to a QgsLayoutItem item and column, if possible.

See also

itemFromIndex()

Parameters:
Return type:

QModelIndex

itemFromIndex(self, index: QModelIndex) QgsLayoutItem | None[source]

Returns the QgsLayoutItem corresponding to a QModelIndex index, if possible.

See also

indexForItem()

Parameters:

index (QModelIndex)

Return type:

Optional[QgsLayoutItem]