Class: QgsLayoutGuide

Contains the configuration for a single snap guide used by a layout.

Class Hierarchy

Inheritance diagram of qgis.core.QgsLayoutGuide

Base classes

QObject

Methods

item

Returns the guide's line item.

layout

Returns the layout the guide belongs to.

layoutPosition

Returns the guide's position in absolute layout units.

orientation

Returns the guide's orientation.

page

Returns the page the guide is contained within.

position

Returns the guide's position within the page.

setLayout

Sets the layout the guide belongs to.

setLayoutPosition

Sets the guide's position in absolute layout units.

setPage

Sets the page the guide is contained within.

setPosition

Sets the guide's position within the page.

update

Updates the position of the guide's line item.

Signals

positionChanged

Emitted when the guide's position is changed.

class qgis.core.QgsLayoutGuide[source]

Bases: QObject

__init__(orientation: Qt.Orientation, position: QgsLayoutMeasurement, page: QgsLayoutItemPage | None)

Constructor for a new guide with the specified orientation and initial position.

A layout must be set by calling setLayout() before the guide can be used. Adding the guide to a QgsLayoutGuideCollection will automatically set the corresponding layout for you.

Parameters:
item(self) QGraphicsLineItem | None[source]

Returns the guide’s line item.

Return type:

Optional[QGraphicsLineItem]

layout(self) QgsLayout | None[source]

Returns the layout the guide belongs to.

See also

setLayout()

Return type:

Optional[QgsLayout]

layoutPosition(self) float[source]

Returns the guide’s position in absolute layout units.

Return type:

float

orientation(self) Qt.Orientation[source]

Returns the guide’s orientation.

Return type:

Qt.Orientation

page(self) QgsLayoutItemPage | None[source]

Returns the page the guide is contained within.

See also

setPage()

Return type:

Optional[QgsLayoutItemPage]

position(self) QgsLayoutMeasurement[source]

Returns the guide’s position within the page.

The position indicates either the horizontal or vertical position of the guide, depending on the guide’s orientation().

See also

setPosition()

Return type:

QgsLayoutMeasurement

signal positionChanged[source]

Emitted when the guide’s position is changed.

setLayout(self, layout: QgsLayout | None)[source]

Sets the layout the guide belongs to.

Note

Adding the guide to a QgsLayoutGuideCollection will automatically set the corresponding layout for you.

See also

layout()

Parameters:

layout (Optional[QgsLayout])

setLayoutPosition(self, position: float)[source]

Sets the guide’s position in absolute layout units.

See also

layoutPosition()

Parameters:

position (float)

setPage(self, page: QgsLayoutItemPage | None)[source]

Sets the page the guide is contained within.

See also

page()

Parameters:

page (Optional[QgsLayoutItemPage])

setPosition(self, position: QgsLayoutMeasurement)[source]

Sets the guide’s position within the page.

The position argument indicates either the horizontal or vertical position of the guide, depending on the guide’s orientation().

See also

position()

Parameters:

position (QgsLayoutMeasurement)

update(self)[source]

Updates the position of the guide’s line item.