Class: QgsLayoutGuideCollection¶
Stores and manages the snap guides used by a layout.
Class Hierarchy¶
Base classes¶
An interface for layout objects which can be stored and read from DOM elements.  | 
|
Interface for layout objects which support undo/redo commands.  | 
Enums
Custom model roles.  | 
|
alias of   | 
Methods
Adds a guide to the collection.  | 
|
Resets all other pages' guides to match the guides from the specified sourcePage.  | 
|
Removes all guides from the collection.  | 
|
Returns a list of all guides contained in the collection.  | 
|
Returns the list of guides contained on a matching page.  | 
|
Sets the collection's state from a DOM element.  | 
|
Removes the specified guide, and deletes it.  | 
|
Sets the absolute position (in layout coordinates) for guide within the layout.  | 
|
Sets whether the guide lines should be visible.  | 
|
Updates the position (and visibility) of all guide line items.  | 
|
Returns   | 
|
Stores the collection's state in a DOM element.  | 
- class qgis.core.QgsLayoutGuideCollection[source]¶
 Bases:
QAbstractTableModel,QgsLayoutSerializableObject- __init__(layout: QgsLayout | None, pageCollection: QgsLayoutPageCollection | None)
 Constructor for QgsLayoutGuideCollection belonging to the specified layout, and linked to the specified
pageCollection.- Parameters:
 layout (Optional[QgsLayout])
pageCollection (Optional[QgsLayoutPageCollection])
- class CustomRole(*values)¶
 Bases:
IntEnumCustom model roles.
Note
Prior to QGIS 3.36 this was available as QgsLayoutGuideCollection.Roles
Added in version 3.36.
Orientation: Guide orientation roleAvailable as
QgsLayoutGuideCollection.OrientationRolein older QGIS releases.Position: Guide position roleAvailable as
QgsLayoutGuideCollection.PositionRolein older QGIS releases.Units: Guide position units roleAvailable as
QgsLayoutGuideCollection.UnitsRolein older QGIS releases.Page: Guide page roleAvailable as
QgsLayoutGuideCollection.PageRolein older QGIS releases.LayoutPosition: Guide position in layout coordinatesAvailable as
QgsLayoutGuideCollection.LayoutPositionRolein older QGIS releases.
- Roles¶
 alias of
CustomRole
- addGuide(self, guide: QgsLayoutGuide | None)[source]¶
 Adds a
guideto the collection. Ownership of the guide is transferred to the collection, and the guide will automatically have the correct layout set.- Parameters:
 guide (Optional[QgsLayoutGuide])
- applyGuidesToAllOtherPages(self, sourcePage: int)[source]¶
 Resets all other pages’ guides to match the guides from the specified
sourcePage.- Parameters:
 sourcePage (int)
- guides(self) List[QgsLayoutGuide]¶
 Returns a list of all guides contained in the collection.
- Return type:
 List[QgsLayoutGuide]
- guides(self, orientation: Qt.Orientation, page: int = -1) List[QgsLayoutGuide]
 Returns the list of guides contained in the collection with the specified
orientationand on a matchingpage. Ifpageis -1, guides from all pages will be returned.See also
- Parameters:
 orientation (Qt.Orientation)
page (int = -1)
- Return type:
 List[QgsLayoutGuide]
- guidesOnPage(self, page: int) List[QgsLayoutGuide]¶
 Returns the list of guides contained on a matching
page.See also
- Parameters:
 page (int)
- Return type:
 List[QgsLayoutGuide]
- readXml(self, collectionElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool[source]¶
 Sets the collection’s state from a DOM element. collectionElement is the DOM node corresponding to the collection.
See also
- Parameters:
 collectionElement (QDomElement)
document (QDomDocument)
context (QgsReadWriteContext)
- Return type:
 bool
- removeGuide(self, guide: QgsLayoutGuide | None)[source]¶
 Removes the specified
guide, and deletes it.See also
- Parameters:
 guide (Optional[QgsLayoutGuide])
- setGuideLayoutPosition(self, guide: QgsLayoutGuide | None, position: float)[source]¶
 Sets the absolute
position(in layout coordinates) forguidewithin the layout.- Parameters:
 guide (Optional[QgsLayoutGuide])
position (float)
- setVisible(self, visible: bool)[source]¶
 Sets whether the guide lines should be
visible.See also
- Parameters:
 visible (bool)
- visible(self) bool[source]¶
 Returns
Trueif the guide lines should be drawn.See also
- Return type:
 bool
- writeXml(self, parentElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool[source]¶
 Stores the collection’s state in a DOM element. The
parentElementshould refer to the parent layout’s DOM element.See also
- Parameters:
 parentElement (QDomElement)
document (QDomDocument)
context (QgsReadWriteContext)
- Return type:
 bool