Class: QgsLayoutGridSettings

class qgis.core.QgsLayoutGridSettings

Bases: QgsLayoutSerializableObject

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

New in version 3.0.

QgsLayoutGridSettings(layout: QgsLayout) Constructor for QgsLayoutGridSettings.

QgsLayoutGridSettings(QgsLayoutGridSettings)

Methods

layout

rtype:

QgsLayout

loadFromSettings

Loads grid settings from the application layout settings.

offset

Returns the offset of the page/snap grid.

pen

Returns the pen used for drawing page/snap grids.

readXml

Sets the grid's state from a DOM element.

resolution

Returns the page/snap grid resolution.

setOffset

Sets the offset of the page/snap grid.

setPen

Sets the pen used for drawing page/snap grids.

setResolution

Sets the page/snap grid resolution.

setStyle

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

stringType

rtype:

str

style

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

writeXml

Stores the grid's state in a DOM element.

Attributes

StyleCrosses

StyleDots

StyleLines

class Style

Bases: int

StyleCrosses = 2
StyleDots = 1
StyleLines = 0
layout(self) QgsLayout
Return type:

QgsLayout

loadFromSettings(self)

Loads grid settings from the application layout settings.

offset(self) QgsLayoutPoint

Returns the offset of the page/snap grid.

See also

setOffset()

See also

resolution()

Return type:

QgsLayoutPoint

pen(self) QPen

Returns the pen used for drawing page/snap grids.

See also

setPen()

See also

style()

Return type:

QPen

readXml(self, gridElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool

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

Returns the page/snap grid resolution.

See also

setResolution()

See also

offset()

Return type:

QgsLayoutMeasurement

setOffset(self, offset: QgsLayoutPoint)

Sets the offset of the page/snap grid.

See also

offset()

See also

setResolution()

Parameters:

offset (QgsLayoutPoint) –

setPen(self, pen: QPen | QColor | Qt.GlobalColor | QGradient)

Sets the pen used for drawing page/snap grids.

See also

pen()

See also

setStyle()

Parameters:

pen (Union[QPen) –

setResolution(self, resolution: QgsLayoutMeasurement)

Sets the page/snap grid resolution.

See also

resolution()

See also

setOffset()

Parameters:

resolution (QgsLayoutMeasurement) –

setStyle(self, style: QgsLayoutGridSettings.Style)

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

See also

style()

See also

setPen()

Parameters:

style (QgsLayoutGridSettings.Style) –

stringType(self) str
Return type:

str

style(self) QgsLayoutGridSettings.Style

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

See also

setStyle()

See also

pen()

Return type:

QgsLayoutGridSettings.Style

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

Stores the grid’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