Class: QgsMapLayerStyle

Stores style information (renderer, opacity, labeling, diagrams etc.) applicable to a map layer.

Stored data are considered as opaque:

  • it is not possible to access them directly or modify them

  • it is only possible to read or write layer’s current style.

class qgis.core.QgsMapLayerStyle[source]

Bases: object

__init__()

construct invalid style

__init__(xmlData: str | None)

construct style from QML definition (XML)

Parameters:

xmlData (Optional[str])

__init__(a0: QgsMapLayerStyle)
Parameters:

a0 (QgsMapLayerStyle)

clear(self)[source]

Remove any stored style data (will get invalid)

isValid(self) bool[source]

Tell whether the style is valid (i.e. there is something stored in it)

Return type:

bool

readFromLayer(self, layer: QgsMapLayer | None)[source]

Store layer’s active style information in the instance

Parameters:

layer (Optional[QgsMapLayer])

readXml(self, styleElement: QDomElement)[source]

Read style configuration (for project file reading)

Parameters:

styleElement (QDomElement)

writeToLayer(self, layer: QgsMapLayer | None)[source]

Apply stored layer’s style information to the layer

Parameters:

layer (Optional[QgsMapLayer])

writeXml(self, styleElement: QDomElement)[source]

Write style configuration (for project file writing)

Parameters:

styleElement (QDomElement)

xmlData(self) str[source]

Returns XML content of the style

Return type:

str