Class: QgsLayoutGuideCollection

class qgis.core.QgsLayoutGuideCollection

Bases: PyQt5.QtCore.QAbstractTableModel, QgsLayoutSerializableObject

Stores and manages the snap guides used by a layout.

New in version 3.0.

QgsLayoutGuideCollection(layout: QgsLayout, pageCollection: QgsLayoutPageCollection) Constructor for QgsLayoutGuideCollection belonging to the specified layout, and linked to the specified pageCollection.

Methods

addGuide

Adds a guide to the collection.

applyGuidesToAllOtherPages

Resets all other pages' guides to match the guides from the specified sourcePage.

beginInsertColumns

beginInsertRows

beginMoveColumns

beginMoveRows

beginRemoveColumns

beginRemoveRows

beginResetModel

changePersistentIndex

changePersistentIndexList

childEvent

clear

Removes all guides from the collection.

columnCount

rtype

int

connectNotify

createIndex

customEvent

data

param index

decodeData

disconnectNotify

encodeData

endInsertColumns

endInsertRows

endMoveColumns

endMoveRows

endRemoveColumns

endRemoveRows

endResetModel

flags

param index

guides

Returns a list of all guides contained in the collection.

guidesOnPage

Returns the list of guides contained on a matching page.

headerData

param section

isSignalConnected

layout

rtype

QgsLayout

persistentIndexList

readXml

Sets the collection's state from a DOM element.

receivers

removeGuide

Removes the specified guide, and deletes it.

removeRows

param row

resetInternalData

rowCount

rtype

int

sender

senderSignalIndex

setData

param index

setGuideLayoutPosition

Sets the absolute position (in layout coordinates) for guide within the layout.

setVisible

Sets whether the guide lines should be visible.

stringType

rtype

str

timerEvent

update

Updates the position (and visibility) of all guide line items.

visible

Returns True if the guide lines should be drawn.

writeXml

Stores the collection's state in a DOM element.

Attributes

LayoutPositionRole

OrientationRole

PageRole

PositionRole

UnitsRole

LayoutPositionRole = 260
OrientationRole = 256
PageRole = 259
PositionRole = 257
class Roles

Bases: int

UnitsRole = 258
addGuide(self, guide: QgsLayoutGuide)

Adds a guide to the collection. Ownership of the guide is transferred to the collection, and the guide will automatically have the correct layout set.

Parameters

guide (QgsLayoutGuide) –

applyGuidesToAllOtherPages(self, sourcePage: int)

Resets all other pages’ guides to match the guides from the specified sourcePage.

Parameters

sourcePage (int) –

QgsLayoutGuideCollection.beginInsertColumns(self, QModelIndex, int, int)
QgsLayoutGuideCollection.beginInsertRows(self, QModelIndex, int, int)
QgsLayoutGuideCollection.beginMoveColumns(self, QModelIndex, int, int, QModelIndex, int) -> bool
QgsLayoutGuideCollection.beginMoveRows(self, QModelIndex, int, int, QModelIndex, int) -> bool
QgsLayoutGuideCollection.beginRemoveColumns(self, QModelIndex, int, int)
QgsLayoutGuideCollection.beginRemoveRows(self, QModelIndex, int, int)
beginResetModel(self)
QgsLayoutGuideCollection.changePersistentIndex(self, QModelIndex, QModelIndex)
changePersistentIndexList(self, Iterable[QModelIndex], Iterable[QModelIndex])
childEvent(self, QChildEvent)
clear(self)

Removes all guides from the collection.

See also

removeGuide()

columnCount(self, QModelIndex) int
Return type

int

connectNotify(self, QMetaMethod)
QgsLayoutGuideCollection.createIndex(self, int, int, object: object = 0) -> QModelIndex
customEvent(self, QEvent)
data(self, index: QModelIndex, role: int) Any
Parameters
  • index (QModelIndex) –

  • role (int) –

Return type

Any

QgsLayoutGuideCollection.decodeData(self, int, int, QModelIndex, QDataStream) -> bool
disconnectNotify(self, QMetaMethod)
encodeData(self, Iterable[QModelIndex], 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

guides(self) List[QgsLayoutGuide]

Returns a list of all guides contained in the collection.

guides(self, orientation: Qt.Orientation, page: int = -1) -> List[QgsLayoutGuide] Returns the list of guides contained in the collection with the specified orientation and on a matching page. If page is -1, guides from all pages will be returned.

See also

guidesOnPage()

Return type

List[QgsLayoutGuide]

guidesOnPage(self, page: int) List[QgsLayoutGuide]

Returns the list of guides contained on a matching page.

See also

guides()

Parameters

page (int) –

Return type

List[QgsLayoutGuide]

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

isSignalConnected(self, QMetaMethod) bool
layout(self) QgsLayout
Return type

QgsLayout

persistentIndexList(self) List[QModelIndex]
readXml(self, collectionElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool

Sets the collection’s state from a DOM element. collectionElement is the DOM node corresponding to the collection.

See also

writeXml()

Parameters
  • collectionElement (QDomElement) –

  • document (QDomDocument) –

  • context (QgsReadWriteContext) –

Return type

bool

receivers(self, PYQT_SIGNAL) int
removeGuide(self, guide: QgsLayoutGuide)

Removes the specified guide, and deletes it.

See also

clear()

Parameters

guide (QgsLayoutGuide) –

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, QModelIndex) int
Return type

int

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

  • value (Any) –

  • role (int) –

Return type

bool

setGuideLayoutPosition(self, guide: QgsLayoutGuide, position: float)

Sets the absolute position (in layout coordinates) for guide within the layout.

Parameters
setVisible(self, visible: bool)

Sets whether the guide lines should be visible.

See also

visible()

Parameters

visible (bool) –

stringType(self) str
Return type

str

timerEvent(self, QTimerEvent)
update(self)

Updates the position (and visibility) of all guide line items.

visible(self) bool

Returns True if the guide lines should be drawn.

See also

setVisible()

Return type

bool

writeXml(self, parentElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool

Stores the collection’s state in a DOM element. The parentElement should refer to the parent layout’s DOM element.

See also

readXml()

Parameters
  • parentElement (QDomElement) –

  • document (QDomDocument) –

  • context (QgsReadWriteContext) –

Return type

bool