QgsLayoutModel class

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.

Public types

enum Columns { Visibility = 0, LockStatus, ItemId }
Columns returned by the model.

Constructors, destructors, conversion operators

QgsLayoutModel(QgsLayout* layout, QObject* parent = nullptr) explicit
Constructor for a QgsLayoutModel attached to the specified layout.

Public functions

auto indexForItem(QgsLayoutItem* item, int column = 0) -> QModelIndex
Returns the QModelIndex corresponding to a QgsLayoutItem item and column, if possible.
auto itemFromIndex(const QModelIndex& index) const -> QgsLayoutItem*
Returns the QgsLayoutItem corresponding to a QModelIndex index, if possible.

Enum documentation

enum QgsLayoutModel::Columns

Columns returned by the model.

Enumerators
Visibility

Item visibility checkbox.

LockStatus

Item lock status checkbox.

ItemId

Item ID.

Function documentation

QModelIndex QgsLayoutModel::indexForItem(QgsLayoutItem* item, int column = 0)

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

QgsLayoutItem* QgsLayoutModel::itemFromIndex(const QModelIndex& index) const

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