Class: QgsLayoutGridSettings

Contains settings relating to the appearance, spacing and offset for layout grids.

Class Hierarchy

Inheritance diagram of qgis.core.QgsLayoutGridSettings

Base classes

QgsLayoutSerializableObject

An interface for layout objects which can be stored and read from DOM elements.

QgsLayoutUndoObjectInterface

Interface for layout objects which support undo/redo commands.

class qgis.core.QgsLayoutGridSettings[source]

Bases: QgsLayoutSerializableObject

__init__(layout: QgsLayout | None)

Constructor for QgsLayoutGridSettings.

Parameters:

layout (Optional[QgsLayout])

__init__(a0: QgsLayoutGridSettings)
Parameters:

a0 (QgsLayoutGridSettings)

class Style

Bases: int

StyleCrosses = 2
StyleDots = 1
StyleLines = 0
loadFromSettings(self)[source]

Loads grid settings from the application layout settings.

offset(self) QgsLayoutPoint[source]

Returns the offset of the page/snap grid.

See also

setOffset()

See also

resolution()

Return type:

QgsLayoutPoint

pen(self) QPen[source]

Returns the pen used for drawing page/snap grids.

See also

setPen()

See also

style()

Return type:

QPen

abstract readXml(self, gridElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool[source]

Sets the grid’s state from a DOM element. gridElement is the DOM node corresponding to the grid.

See also

writeXml()

Parameters:
Return type:

bool

resolution(self) QgsLayoutMeasurement[source]

Returns the page/snap grid resolution.

See also

setResolution()

See also

offset()

Return type:

QgsLayoutMeasurement

setOffset(self, offset: QgsLayoutPoint)[source]

Sets the offset of the page/snap grid.

See also

offset()

See also

setResolution()

Parameters:

offset (QgsLayoutPoint)

setPen(self, pen: QPen | QColor | Qt.GlobalColor)[source]

Sets the pen used for drawing page/snap grids.

See also

pen()

See also

setStyle()

Parameters:

pen (Union[QPen, Union[QColor, Qt.GlobalColor]])

setResolution(self, resolution: QgsLayoutMeasurement)[source]

Sets the page/snap grid resolution.

See also

resolution()

See also

setOffset()

Parameters:

resolution (QgsLayoutMeasurement)

setStyle(self, style: QgsLayoutGridSettings.Style)[source]

Sets the style used for drawing the page/snap grids.

See also

style()

See also

setPen()

Parameters:

style (QgsLayoutGridSettings.Style)

style(self) QgsLayoutGridSettings.Style[source]

Returns the style used for drawing the page/snap grids.

See also

setStyle()

See also

pen()

Return type:

QgsLayoutGridSettings.Style

abstract writeXml(self, parentElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool[source]

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

See also

readXml()

Parameters:
Return type:

bool