Class: QgsLayoutModel

class qgis.core.QgsLayoutModel

Bases: PyQt5.QtCore.QAbstractItemModel

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.

QgsLayoutModel(layout: Optional[QgsLayout], parent: Optional[QObject] = None) Constructor for a QgsLayoutModel attached to the specified layout.

Methods

beginInsertColumns

beginInsertRows

beginMoveColumns

beginMoveRows

beginRemoveColumns

beginRemoveRows

beginResetModel

changePersistentIndex

changePersistentIndexList

childEvent

columnCount

param parent:

connectNotify

createIndex

customEvent

data

param index:

decodeData

disconnectNotify

dropMimeData

param data:

encodeData

endInsertColumns

endInsertRows

endMoveColumns

endMoveRows

endRemoveColumns

endRemoveRows

endResetModel

flags

param index:

headerData

param section:

index

param row:

indexForItem

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

isSignalConnected

itemFromIndex

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

mimeData

param indexes:

mimeTypes

rtype:

List[str]

parent

param index:

persistentIndexList

receivers

removeRows

param row:

resetInternalData

rowCount

param parent:

sender

senderSignalIndex

setData

param index:

supportedDropActions

rtype:

Qt.DropActions

timerEvent

Attributes

ItemId

LockStatus

Visibility

class Columns

Bases: int

ItemId = 2
LockStatus = 1
Visibility = 0
beginInsertColumns(self, parent: QModelIndex, first: int, last: int)
beginInsertRows(self, parent: QModelIndex, first: int, last: int)
beginMoveColumns(self, sourceParent: QModelIndex, sourceFirst: int, sourceLast: int, destinationParent: QModelIndex, destinationColumn: int) bool
beginMoveRows(self, sourceParent: QModelIndex, sourceFirst: int, sourceLast: int, destinationParent: QModelIndex, destinationRow: int) bool
beginRemoveColumns(self, parent: QModelIndex, first: int, last: int)
beginRemoveRows(self, parent: QModelIndex, first: int, last: int)
beginResetModel(self)
changePersistentIndex(self, from_: QModelIndex, to: QModelIndex)
changePersistentIndexList(self, from_: Iterable[QModelIndex], to: Iterable[QModelIndex])
childEvent(self, a0: QChildEvent | None)
columnCount(self, parent: QModelIndex = QModelIndex()) int
Parameters:

parent (QModelIndex = QModelIndex())

Return type:

int

connectNotify(self, signal: QMetaMethod)
createIndex(self, row: int, column: int, object: Any = None) QModelIndex
customEvent(self, a0: QEvent | None)
data(self, index: QModelIndex, role: int) Any
Parameters:
  • index (QModelIndex)

  • role (int)

Return type:

Any

decodeData(self, row: int, column: int, parent: QModelIndex, stream: QDataStream) bool
disconnectNotify(self, signal: QMetaMethod)
dropMimeData(self, data: QMimeData | None, action: Qt.DropAction, row: int, column: int, parent: QModelIndex) bool
Parameters:
  • data (Optional[QMimeData])

  • action (Qt.DropAction)

  • row (int)

  • column (int)

  • parent (QModelIndex)

Return type:

bool

encodeData(self, indexes: Iterable[QModelIndex], stream: QDataStream)
endInsertColumns(self)
endInsertRows(self)
endMoveColumns(self)
endMoveRows(self)
endRemoveColumns(self)
endRemoveRows(self)
endResetModel(self)
flags(self, index: QModelIndex) Qt.ItemFlags
Parameters:

index (QModelIndex)

Return type:

Qt.ItemFlags

headerData(self, section: int, orientation: Qt.Orientation, role: int = Qt.DisplayRole) Any
Parameters:
  • section (int)

  • orientation (Qt.Orientation)

  • role (int = Qt.DisplayRole)

Return type:

Any

index(self, row: int, column: int, parent: QModelIndex = QModelIndex()) QModelIndex
Parameters:
  • row (int)

  • column (int)

  • parent (QModelIndex = QModelIndex())

Return type:

QModelIndex

indexForItem(self, item: QgsLayoutItem | None, column: int = 0) QModelIndex

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

See also

itemFromIndex()

Parameters:
Return type:

QModelIndex

isSignalConnected(self, signal: QMetaMethod) bool
itemFromIndex(self, index: QModelIndex) QgsLayoutItem | None

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

See also

indexForItem()

Parameters:

index (QModelIndex)

Return type:

Optional[QgsLayoutItem]

mimeData(self, indexes: Iterable[QModelIndex]) QMimeData | None
Parameters:

indexes (Iterable[QModelIndex])

Return type:

Optional[QMimeData]

mimeTypes(self) List[str]
Return type:

List[str]

parent(self, index: QModelIndex) QModelIndex
Parameters:

index (QModelIndex)

Return type:

QModelIndex

persistentIndexList(self) List[QModelIndex]
receivers(self, signal: PYQT_SIGNAL) int
removeRows(self, row: int, count: int, parent: QModelIndex = QModelIndex()) bool
Parameters:
  • row (int)

  • count (int)

  • parent (QModelIndex = QModelIndex())

Return type:

bool

resetInternalData(self)
rowCount(self, parent: QModelIndex = QModelIndex()) int
Parameters:

parent (QModelIndex = QModelIndex())

Return type:

int

sender(self) QObject | None
senderSignalIndex(self) int
setData(self, index: QModelIndex, value: Any, role: int) bool
Parameters:
  • index (QModelIndex)

  • value (Any)

  • role (int)

Return type:

bool

supportedDropActions(self) Qt.DropActions
Return type:

Qt.DropActions

timerEvent(self, a0: QTimerEvent | None)