Class: QgsSymbolLayer

Abstract base class for symbol layers.

Note

This is an abstract class, with methods which must be implemented by a subclass.

The following methods must be implemented: clone(), drawPreviewIcon(), layerType(), properties(), startRender(), stopRender()

Class Hierarchy

Inheritance diagram of qgis.core.QgsSymbolLayer

Subclasses

QgsLineSymbolLayer

Abstract base class for line symbol layers.

QgsMarkerSymbolLayer

Abstract base class for marker symbol layers.

QgsFillSymbolLayer

Abstract base class for fill symbol layers.

QgsGeometryGeneratorSymbolLayer

A symbol layer subclass which alters rendered feature shapes through the use of QGIS expressions.

Enums

Property

Data definable properties.

Abstract Methods

clone

Shall be reimplemented by subclasses to create a deep copy of the instance.

drawPreviewIcon

layerType

Returns a string that represents this layer type.

properties

Should be reimplemented by subclasses to return a string map that contains the configuration information for the symbol layer.

startRender

Called before a set of rendering operations commences on the supplied render context.

stopRender

Called after a set of rendering operations has finished on the supplied render context.

Methods

copyDataDefinedProperties

Copies all data defined properties of this layer to another symbol layer.

copyPaintEffect

Copies paint effect of this layer to another symbol layer

dataDefinedProperties

Returns a reference to the symbol layer's property collection, used for data defined overrides.

enabled

Returns True if symbol layer is enabled and will be drawn.

id

Returns symbol layer identifier This id is unique in the whole project

installMasks

When rendering, install masks on context painter.

isLocked

Returns True if the symbol layer colors are locked and the layer will ignore any symbol-level color changes.

paintEffect

Returns the current paint effect for the layer.

propertyDefinitions

Returns the symbol layer property definitions.

removeMasks

When rendering, remove previously installed masks from context painter if recursive is True masks are removed recursively for all children symbol layers

renderingPass

Specifies the rendering pass in which this symbol layer should be rendered.

restoreOldDataDefinedProperties

Restores older data defined properties from string map.

setDataDefinedProperties

Sets the symbol layer's property collection, used for data defined overrides.

setEnabled

Sets whether symbol layer is enabled and should be drawn.

setId

Set symbol layer identifier This id has to be unique in the whole project

setLocked

Sets whether the layer's colors are locked.

setPaintEffect

Sets the current paint effect for the layer.

setRenderingPass

Specifies the rendering pass in which this symbol layer should be rendered.

setUserFlags

Sets user-controlled flags which control the symbol layer's behavior.

shouldRenderUsingSelectionColor

Returns True if the symbol layer should be rendered using the selection color from the render context.

type

userFlags

Returns user-controlled flags which control the symbol layer's behavior.

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsSymbolLayer. See the FAQ for more details.

canCauseArtifactsBetweenAdjacentTiles

Returns True if the symbol layer rendering can cause visible artifacts across a single feature when the feature is rendered as a series of adjacent map tiles each containing a portion of the feature's geometry.

color

Returns the "representative" color of the symbol layer.

dxfAngle

Gets angle

dxfBrushColor

Gets brush/fill color

dxfBrushStyle

Gets brush/fill style

dxfColor

Gets color

dxfCustomDashPattern

Gets dash pattern

dxfOffset

Gets offset

dxfPenStyle

Gets pen style

dxfSize

Gets marker size

dxfWidth

Gets line width

estimateMaxBleed

Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when drawn in the specified /a context.

fillColor

Returns the fill color for the symbol layer.

flags

Returns flags which control the symbol layer's behavior.

hasDataDefinedProperties

Returns True if the symbol layer (or any of its sub-symbols) contains data defined properties.

isCompatibleWithSymbol

Returns if the layer can be used below the specified symbol

mapUnitScale

masks

Returns masks defined by this symbol layer.

ogrFeatureStyle

outputUnit

Returns the units to use for sizes and widths within the symbol layer.

prepareExpressions

Prepares all data defined property expressions for evaluation.

prepareMasks

Prepares all mask internal objects according to what is defined in context This should be called prior to calling startRender() method.

setColor

Sets the "representative" color for the symbol layer.

setDataDefinedProperty

Sets a data defined property for the layer.

setFillColor

Sets the fill color for the symbol layer.

setMapUnitScale

setOutputUnit

Sets the units to use for sizes and widths within the symbol layer.

setStrokeColor

Sets the stroke color for the symbol layer.

setSubSymbol

Sets layer's subsymbol.

startFeatureRender

Called before the layer will be rendered for a particular feature.

stopFeatureRender

Called after the layer has been rendered for a particular feature.

strokeColor

Returns the stroke color for the symbol layer.

subSymbol

Returns the symbol's sub symbol, if present.

toSld

Saves the symbol layer as SLD.

usedAttributes

Returns the set of attributes referenced by the layer.

usesMapUnits

Returns True if the symbol layer has any components which use map unit based sizes.

writeDxf

write as DXF

class qgis.core.QgsSymbolLayer[source]

Bases: object

__init__(type: Qgis.SymbolType, locked: bool = False)

Constructor for QgsSymbolLayer.

Parameters:
  • type (Qgis.SymbolType) – specifies the associated symbol type

  • locked (bool = False) – if True, then symbol layer colors will be locked and will ignore any symbol-level color changes.

class Property(*values)

Bases: IntEnum

Data definable properties.

  • Size: Symbol size

    Available as QgsSymbolLayer.PropertySize in older QGIS releases.

  • Angle: Symbol angle

    Available as QgsSymbolLayer.PropertyAngle in older QGIS releases.

  • Name: Name, eg shape name for simple markers

    Available as QgsSymbolLayer.PropertyName in older QGIS releases.

  • FillColor: Fill color

    Available as QgsSymbolLayer.PropertyFillColor in older QGIS releases.

  • StrokeColor: Stroke color

    Available as QgsSymbolLayer.PropertyStrokeColor in older QGIS releases.

  • StrokeWidth: Stroke width

    Available as QgsSymbolLayer.PropertyStrokeWidth in older QGIS releases.

  • StrokeStyle: Stroke style (eg solid, dashed)

    Available as QgsSymbolLayer.PropertyStrokeStyle in older QGIS releases.

  • Offset: Symbol offset

    Available as QgsSymbolLayer.PropertyOffset in older QGIS releases.

  • Character: Character, eg for font marker symbol layers

    Available as QgsSymbolLayer.PropertyCharacter in older QGIS releases.

  • Width: Symbol width

    Available as QgsSymbolLayer.PropertyWidth in older QGIS releases.

  • Height: Symbol height

    Available as QgsSymbolLayer.PropertyHeight in older QGIS releases.

  • PreserveAspectRatio: Preserve aspect ratio between width and height

    Available as QgsSymbolLayer.PropertyPreserveAspectRatio in older QGIS releases.

  • FillStyle: Fill style (eg solid, dots)

    Available as QgsSymbolLayer.PropertyFillStyle in older QGIS releases.

  • JoinStyle: Line join style

    Available as QgsSymbolLayer.PropertyJoinStyle in older QGIS releases.

  • SecondaryColor: Secondary color (eg for gradient fills)

    Available as QgsSymbolLayer.PropertySecondaryColor in older QGIS releases.

  • LineAngle: Line angle, or angle of hash lines for hash line symbols

    Available as QgsSymbolLayer.PropertyLineAngle in older QGIS releases.

  • LineDistance: Distance between lines, or length of lines for hash line symbols

    Available as QgsSymbolLayer.PropertyLineDistance in older QGIS releases.

  • GradientType: Gradient fill type

    Available as QgsSymbolLayer.PropertyGradientType in older QGIS releases.

  • CoordinateMode: Gradient coordinate mode

    Available as QgsSymbolLayer.PropertyCoordinateMode in older QGIS releases.

  • GradientSpread: Gradient spread mode

    Available as QgsSymbolLayer.PropertyGradientSpread in older QGIS releases.

  • GradientReference1X: Gradient reference point 1 x

    Available as QgsSymbolLayer.PropertyGradientReference1X in older QGIS releases.

  • GradientReference1Y: Gradient reference point 1 y

    Available as QgsSymbolLayer.PropertyGradientReference1Y in older QGIS releases.

  • GradientReference2X: Gradient reference point 2 x

    Available as QgsSymbolLayer.PropertyGradientReference2X in older QGIS releases.

  • GradientReference2Y: Gradient reference point 2 y

    Available as QgsSymbolLayer.PropertyGradientReference2Y in older QGIS releases.

  • GradientReference1IsCentroid: Gradient reference point 1 is centroid

    Available as QgsSymbolLayer.PropertyGradientReference1IsCentroid in older QGIS releases.

  • GradientReference2IsCentroid: Gradient reference point 2 is centroid

    Available as QgsSymbolLayer.PropertyGradientReference2IsCentroid in older QGIS releases.

  • BlurRadius: Shapeburst blur radius

    Available as QgsSymbolLayer.PropertyBlurRadius in older QGIS releases.

  • ShapeburstUseWholeShape: Shapeburst use whole shape

    Available as QgsSymbolLayer.PropertyShapeburstUseWholeShape in older QGIS releases.

  • ShapeburstMaxDistance: Shapeburst fill from edge distance

    Available as QgsSymbolLayer.PropertyShapeburstMaxDistance in older QGIS releases.

  • ShapeburstIgnoreRings: Shapeburst ignore rings

    Available as QgsSymbolLayer.PropertyShapeburstIgnoreRings in older QGIS releases.

  • File: Filename, eg for svg files

    Available as QgsSymbolLayer.PropertyFile in older QGIS releases.

  • DistanceX: Horizontal distance between points

    Available as QgsSymbolLayer.PropertyDistanceX in older QGIS releases.

  • DistanceY: Vertical distance between points

    Available as QgsSymbolLayer.PropertyDistanceY in older QGIS releases.

  • DisplacementX: Horizontal displacement

    Available as QgsSymbolLayer.PropertyDisplacementX in older QGIS releases.

  • DisplacementY: Vertical displacement

    Available as QgsSymbolLayer.PropertyDisplacementY in older QGIS releases.

  • Opacity: Opacity

    Available as QgsSymbolLayer.PropertyOpacity in older QGIS releases.

  • CustomDash: Custom dash pattern

    Available as QgsSymbolLayer.PropertyCustomDash in older QGIS releases.

  • CapStyle: Line cap style

    Available as QgsSymbolLayer.PropertyCapStyle in older QGIS releases.

  • Placement: Line marker placement

    Available as QgsSymbolLayer.PropertyPlacement in older QGIS releases.

  • Interval: Line marker interval

    Available as QgsSymbolLayer.PropertyInterval in older QGIS releases.

  • OffsetAlongLine: Offset along line

    Available as QgsSymbolLayer.PropertyOffsetAlongLine in older QGIS releases.

  • AverageAngleLength: Length to average symbol angles over

    Available as QgsSymbolLayer.PropertyAverageAngleLength in older QGIS releases.

  • HorizontalAnchor: Horizontal anchor point

    Available as QgsSymbolLayer.PropertyHorizontalAnchor in older QGIS releases.

  • VerticalAnchor: Vertical anchor point

    Available as QgsSymbolLayer.PropertyVerticalAnchor in older QGIS releases.

  • LayerEnabled: Whether symbol layer is enabled

    Available as QgsSymbolLayer.PropertyLayerEnabled in older QGIS releases.

  • ArrowWidth: Arrow tail width

    Available as QgsSymbolLayer.PropertyArrowWidth in older QGIS releases.

  • ArrowStartWidth: Arrow tail start width

    Available as QgsSymbolLayer.PropertyArrowStartWidth in older QGIS releases.

  • ArrowHeadLength: Arrow head length

    Available as QgsSymbolLayer.PropertyArrowHeadLength in older QGIS releases.

  • ArrowHeadThickness: Arrow head thickness

    Available as QgsSymbolLayer.PropertyArrowHeadThickness in older QGIS releases.

  • ArrowHeadType: Arrow head type

    Available as QgsSymbolLayer.PropertyArrowHeadType in older QGIS releases.

  • ArrowType: Arrow type

    Available as QgsSymbolLayer.PropertyArrowType in older QGIS releases.

  • OffsetX: Horizontal offset

    Available as QgsSymbolLayer.PropertyOffsetX in older QGIS releases.

  • OffsetY: Vertical offset

    Available as QgsSymbolLayer.PropertyOffsetY in older QGIS releases.

  • PointCount: Point count

    Available as QgsSymbolLayer.PropertyPointCount in older QGIS releases.

  • RandomSeed: Random number seed

    Available as QgsSymbolLayer.PropertyRandomSeed in older QGIS releases.

  • ClipPoints: Whether markers should be clipped to polygon boundaries

    Available as QgsSymbolLayer.PropertyClipPoints in older QGIS releases.

  • DensityArea: Density area

    Available as QgsSymbolLayer.PropertyDensityArea in older QGIS releases.

  • FontFamily: Font family

    Available as QgsSymbolLayer.PropertyFontFamily in older QGIS releases.

  • FontStyle: Font style

    Available as QgsSymbolLayer.PropertyFontStyle in older QGIS releases.

  • DashPatternOffset: Dash pattern offset,

    Available as QgsSymbolLayer.PropertyDashPatternOffset in older QGIS releases.

  • TrimStart: Trim distance from start of line

    Added in version 3.20.

    Available as QgsSymbolLayer.PropertyTrimStart in older QGIS releases.

  • TrimEnd: Trim distance from end of line

    Added in version 3.20.

    Available as QgsSymbolLayer.PropertyTrimEnd in older QGIS releases.

  • LineStartWidthValue: Start line width for interpolated line renderer

    Added in version 3.22.

    Available as QgsSymbolLayer.PropertyLineStartWidthValue in older QGIS releases.

  • LineEndWidthValue: End line width for interpolated line renderer

    Added in version 3.22.

    Available as QgsSymbolLayer.PropertyLineEndWidthValue in older QGIS releases.

  • LineStartColorValue: Start line color for interpolated line renderer

    Added in version 3.22.

    Available as QgsSymbolLayer.PropertyLineStartColorValue in older QGIS releases.

  • LineEndColorValue: End line color for interpolated line renderer

    Added in version 3.22.

    Available as QgsSymbolLayer.PropertyLineEndColorValue in older QGIS releases.

  • MarkerClipping: Marker clipping mode

    Added in version 3.24.

    Available as QgsSymbolLayer.PropertyMarkerClipping in older QGIS releases.

  • RandomOffsetX: Random offset X

    Added in version 3.24.

    Available as QgsSymbolLayer.PropertyRandomOffsetX in older QGIS releases.

  • RandomOffsetY: Random offset Y

    Added in version 3.24.

    Available as QgsSymbolLayer.PropertyRandomOffsetY in older QGIS releases.

  • LineClipping: Line clipping mode

    Added in version 3.24.

    Available as QgsSymbolLayer.PropertyLineClipping in older QGIS releases.

  • SkipMultiples: Skip multiples of

    Added in version 3.40.

  • ShowMarker: Show markers

    Added in version 3.40.

virtual canCauseArtifactsBetweenAdjacentTiles(self) bool[source]

Returns True if the symbol layer rendering can cause visible artifacts across a single feature when the feature is rendered as a series of adjacent map tiles each containing a portion of the feature’s geometry.

The default implementation returns False.

Added in version 3.18.

Return type:

bool

abstract clone(self) QgsSymbolLayer | None[source]

Shall be reimplemented by subclasses to create a deep copy of the instance.

Return type:

Optional[QgsSymbolLayer]

virtual color(self) QColor[source]

Returns the “representative” color of the symbol layer.

Depending on the symbol layer type, this will have different meaning. For instance, a line symbol layer will generally return the stroke color of the layer, while a fill symbol layer will return the “fill” color instead of stroke.

Some symbol layer types will return an invalid QColor if they have no representative color associated (e.g. raster image based symbol layers).

See also

setColor()

See also

strokeColor()

See also

fillColor()

Return type:

QColor

copyDataDefinedProperties(self, destLayer: QgsSymbolLayer | None)[source]

Copies all data defined properties of this layer to another symbol layer.

Parameters:

destLayer (Optional[QgsSymbolLayer]) – destination layer

copyPaintEffect(self, destLayer: QgsSymbolLayer | None)[source]

Copies paint effect of this layer to another symbol layer

Parameters:

destLayer (Optional[QgsSymbolLayer]) – destination layer

dataDefinedProperties(self) QgsPropertyCollection

Returns a reference to the symbol layer’s property collection, used for data defined overrides.

See also

Property

Return type:

QgsPropertyCollection

abstract drawPreviewIcon(self, context: QgsSymbolRenderContext, size: QSize)[source]
Parameters:
virtual dxfAngle(self, context: QgsSymbolRenderContext) float[source]

Gets angle

Parameters:

context (QgsSymbolRenderContext)

Return type:

float

virtual dxfBrushColor(self, context: QgsSymbolRenderContext) QColor[source]

Gets brush/fill color

Parameters:

context (QgsSymbolRenderContext)

Return type:

QColor

virtual dxfBrushStyle(self) Qt.BrushStyle[source]

Gets brush/fill style

Return type:

Qt.BrushStyle

virtual dxfColor(self, context: QgsSymbolRenderContext) QColor[source]

Gets color

Parameters:

context (QgsSymbolRenderContext)

Return type:

QColor

virtual dxfCustomDashPattern(self)

Gets dash pattern

virtual dxfOffset(self, e: QgsDxfExport, context: QgsSymbolRenderContext) float[source]

Gets offset

Parameters:
Return type:

float

virtual dxfPenStyle(self) Qt.PenStyle[source]

Gets pen style

Return type:

Qt.PenStyle

virtual dxfSize(self, e: QgsDxfExport, context: QgsSymbolRenderContext) float[source]

Gets marker size

Parameters:
Return type:

float

virtual dxfWidth(self, e: QgsDxfExport, context: QgsSymbolRenderContext) float[source]

Gets line width

Parameters:
Return type:

float

enabled(self) bool[source]

Returns True if symbol layer is enabled and will be drawn.

See also

setEnabled()

Return type:

bool

virtual estimateMaxBleed(self, context: QgsRenderContext) float[source]

Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when drawn in the specified /a context. For example, polygons drawn with an stroke will draw half the width of the stroke outside of the polygon. This amount is estimated, since it may be affected by data defined symbology rules.

Parameters:

context (QgsRenderContext)

Return type:

float

virtual fillColor(self) QColor[source]

Returns the fill color for the symbol layer.

This property is not supported by all symbol layer types, only those with a fill component. Symbol layers without a fill component will return an invalid QColor.

See also

setFillColor()

See also

color()

See also

strokeColor()

Return type:

QColor

virtual flags(self) Qgis.SymbolLayerFlags[source]

Returns flags which control the symbol layer’s behavior.

Added in version 3.22.

Return type:

Qgis.SymbolLayerFlags

virtual hasDataDefinedProperties(self) bool[source]

Returns True if the symbol layer (or any of its sub-symbols) contains data defined properties.

Added in version 3.4.5.

Return type:

bool

id(self) str[source]

Returns symbol layer identifier This id is unique in the whole project

Added in version 3.30.

Return type:

str

installMasks(self, context: QgsRenderContext, recursive: bool, rect: QRectF = QRectF()) bool[source]

When rendering, install masks on context painter.

If recursive is True masks are installed recursively for all children symbol layers.

Since QGIS 3.38 the rect argument can be used to specify a target bounds (in painter coordinates) for mask geometries. Only mask geometries which intersect rect will be installed.

Return type:

bool

Returns:

True if any masks were installed (since QGIS 3.38)

See also

prepareMasks()

See also

removeMasks()

Added in version 3.30.

Parameters:
virtual isCompatibleWithSymbol(self, symbol: QgsSymbol | None) bool[source]

Returns if the layer can be used below the specified symbol

Parameters:

symbol (Optional[QgsSymbol])

Return type:

bool

isLocked(self) bool[source]

Returns True if the symbol layer colors are locked and the layer will ignore any symbol-level color changes.

See also

setLocked()

Return type:

bool

abstract layerType(self) str[source]

Returns a string that represents this layer type. Used for serialization. Should match with the string used to register this symbol layer in the registry.

Return type:

str

virtual mapUnitScale(self) QgsMapUnitScale[source]
Return type:

QgsMapUnitScale

virtual masks(self) List[QgsSymbolLayerReference]

Returns masks defined by this symbol layer. This is a list of symbol layers of other layers that should be occluded.

Added in version 3.12.

Return type:

List[QgsSymbolLayerReference]

virtual ogrFeatureStyle(self, mmScaleFactor: float, mapUnitScaleFactor: float) str[source]
Parameters:
  • mmScaleFactor (float)

  • mapUnitScaleFactor (float)

Return type:

str

virtual outputUnit(self) Qgis.RenderUnit[source]

Returns the units to use for sizes and widths within the symbol layer. Individual symbol layer subclasses will interpret this in different ways, e.g., a marker symbol layer may use it to specify the units for the marker size, while a line symbol layer may use it to specify the units for the line width.

Return type:

Qgis.RenderUnit

Returns:

output unit, or QgsUnitTypes.RenderUnknownUnit if the symbol layer contains mixed units

See also

setOutputUnit()

paintEffect(self) QgsPaintEffect | None[source]

Returns the current paint effect for the layer.

Return type:

Optional[QgsPaintEffect]

Returns:

paint effect

See also

setPaintEffect()

virtual prepareExpressions(self, context: QgsSymbolRenderContext)[source]

Prepares all data defined property expressions for evaluation. This should be called prior to evaluating data defined properties.

Parameters:

context (QgsSymbolRenderContext) – symbol render context

virtual prepareMasks(self, context: QgsSymbolRenderContext)[source]

Prepares all mask internal objects according to what is defined in context This should be called prior to calling startRender() method.

Added in version 3.26.

Parameters:

context (QgsSymbolRenderContext)

abstract properties(self) Dict[str, Any][source]

Should be reimplemented by subclasses to return a string map that contains the configuration information for the symbol layer. This is used to serialize a symbol layer perstistently.

Return type:

Dict[str, Any]

propertyDefinitions() Dict[int, QgsPropertyDefinition]

Returns the symbol layer property definitions.

Return type:

Dict[int, QgsPropertyDefinition]

removeMasks(self, context: QgsRenderContext, recursive: bool)[source]

When rendering, remove previously installed masks from context painter if recursive is True masks are removed recursively for all children symbol layers

See also

prepareMasks()

See also

installMasks()

Added in version 3.30.

Parameters:
renderingPass(self) int[source]

Specifies the rendering pass in which this symbol layer should be rendered. The lower the number, the lower the symbol will be rendered. 0: first pass, 1: second pass, … Defaults to 0

Return type:

int

restoreOldDataDefinedProperties(self, stringMap: Dict[str, Any])[source]

Restores older data defined properties from string map.

Parameters:

stringMap (Dict[str, Any])

virtual setColor(self, color: QColor | Qt.GlobalColor)[source]

Sets the “representative” color for the symbol layer.

Depending on the symbol layer type, this will have different meaning. For instance, a line symbol layer will generally set the stroke color of the layer, while a fill symbol layer will set the “fill” color instead of stroke.

See also

color()

See also

setStrokeColor()

See also

setFillColor()

Parameters:

color (Union[QColor, Qt.GlobalColor])

setDataDefinedProperties(self, collection: QgsPropertyCollection)[source]

Sets the symbol layer’s property collection, used for data defined overrides.

Parameters:

collection (QgsPropertyCollection) – property collection. Existing properties will be replaced.

virtual setDataDefinedProperty(self, key: QgsSymbolLayer.Property, property: QgsProperty)[source]

Sets a data defined property for the layer. Any existing property with the same key will be overwritten.

See also

Property

Parameters:
setEnabled(self, enabled: bool)[source]

Sets whether symbol layer is enabled and should be drawn. Disabled layers are not drawn, but remain part of the symbol and can be re-enabled when desired.

See also

enabled()

Parameters:

enabled (bool)

virtual setFillColor(self, color: QColor | Qt.GlobalColor)[source]

Sets the fill color for the symbol layer.

This property is not supported by all symbol layer types, only those with a fill component.

See also

fillColor()

See also

setColor()

See also

setStrokeColor()

Parameters:

color (Union[QColor, Qt.GlobalColor])

setId(self, id: str | None)[source]

Set symbol layer identifier This id has to be unique in the whole project

Added in version 3.30.

Parameters:

id (Optional[str])

setLocked(self, locked: bool)[source]

Sets whether the layer’s colors are locked.

If locked is True then the symbol layer colors are locked and the layer will ignore any symbol-level color changes.

See also

isLocked()

Parameters:

locked (bool)

virtual setMapUnitScale(self, scale: QgsMapUnitScale)[source]
Parameters:

scale (QgsMapUnitScale)

virtual setOutputUnit(self, unit: Qgis.RenderUnit)[source]

Sets the units to use for sizes and widths within the symbol layer. Individual symbol layer subclasses will interpret this in different ways, e.g., a marker symbol layer may use it to specify the units for the marker size, while a line symbol layer may use it to specify the units for the line width.

Parameters:

unit (Qgis.RenderUnit) – output units

See also

outputUnit()

setPaintEffect(self, effect: QgsPaintEffect | None)[source]

Sets the current paint effect for the layer.

Parameters:

effect (Optional[QgsPaintEffect]) – paint effect. Ownership is transferred to the layer.

See also

paintEffect()

setRenderingPass(self, renderingPass: int)[source]

Specifies the rendering pass in which this symbol layer should be rendered. The lower the number, the lower the symbol will be rendered. 0: first pass, 1: second pass, … Defaults to 0

Parameters:

renderingPass (int)

virtual setStrokeColor(self, color: QColor | Qt.GlobalColor)[source]

Sets the stroke color for the symbol layer.

This property is not supported by all symbol layer types, only those with a stroke component.

See also

strokeColor()

See also

setColor()

See also

setFillColor()

Parameters:

color (Union[QColor, Qt.GlobalColor])

virtual setSubSymbol(self, symbol: QgsSymbol | None) bool[source]

Sets layer’s subsymbol. takes ownership of the passed symbol

Parameters:

symbol (Optional[QgsSymbol])

Return type:

bool

setUserFlags(self, flags: Qgis.SymbolLayerUserFlags | Qgis.SymbolLayerUserFlag)[source]

Sets user-controlled flags which control the symbol layer’s behavior.

See also

userFlags()

Added in version 3.34.

Parameters:

flags (Union[Qgis.SymbolLayerUserFlags, Qgis.SymbolLayerUserFlag])

shouldRenderUsingSelectionColor(self, context: QgsSymbolRenderContext) bool[source]

Returns True if the symbol layer should be rendered using the selection color from the render context.

Added in version 3.34.

Parameters:

context (QgsSymbolRenderContext)

Return type:

bool

virtual startFeatureRender(self, feature: QgsFeature, context: QgsRenderContext)[source]

Called before the layer will be rendered for a particular feature.

This is always followed by a call to stopFeatureRender() after the feature has been completely rendered (i.e. all parts have been rendered).

The default implementation does nothing.

Note

In some circumstances, startFeatureRender() and stopFeatureRender() may not be called before a symbol layer is rendered. E.g., when a symbol layer is being rendered in isolation and not as a result of rendering a feature (for instance, when rendering a legend patch or other non-feature based shape).

See also

startRender()

Added in version 3.12.

Parameters:
abstract startRender(self, context: QgsSymbolRenderContext)[source]

Called before a set of rendering operations commences on the supplied render context.

This is always followed by a call to stopRender() after all rendering operations have been completed.

Subclasses can use this method to prepare for a set of rendering operations, e.g. by pre-evaluating paths or images to render, and performing other one-time optimisations.

See also

stopRender()

Parameters:

context (QgsSymbolRenderContext)

virtual stopFeatureRender(self, feature: QgsFeature, context: QgsRenderContext)[source]

Called after the layer has been rendered for a particular feature.

This is always preceded by a call to startFeatureRender() just before the feature will be rendered.

The default implementation does nothing.

Note

In some circumstances, startFeatureRender() and stopFeatureRender() may not be called before a symbol layer is rendered. E.g., when a symbol layer is being rendered in isolation and not as a result of rendering a feature (for instance, when rendering a legend patch or other non-feature based shape).

See also

stopRender()

Added in version 3.12.

Parameters:
abstract stopRender(self, context: QgsSymbolRenderContext)[source]

Called after a set of rendering operations has finished on the supplied render context.

This is always preceded by a call to startRender() before all rendering operations are commenced.

Subclasses can use this method to cleanup after a set of rendering operations.

See also

startRender()

Parameters:

context (QgsSymbolRenderContext)

virtual strokeColor(self) QColor[source]

Returns the stroke color for the symbol layer.

This property is not supported by all symbol layer types, only those with a stroke component. Symbol layers without a stroke component will return an invalid QColor.

See also

setStrokeColor()

See also

color()

See also

fillColor()

Return type:

QColor

virtual subSymbol(self) QgsSymbol | None[source]

Returns the symbol’s sub symbol, if present.

Return type:

Optional[QgsSymbol]

virtual toSld(self, doc: QDomDocument, element: QDomElement, props: Dict[str, Any])[source]

Saves the symbol layer as SLD.

Deprecated since version 3.44: Use the version with QgsSldExportContext instead.

Parameters:
  • doc (QDomDocument)

  • element (QDomElement)

  • props (Dict[str, Any])

virtual toSld(self, doc: QDomDocument, element: QDomElement, context: QgsSldExportContext) bool[source]

Saves the symbol layer as SLD.

Returns True if the symbol layer was successfully exported to SLD.

Added in version 3.44.

Parameters:
Return type:

bool

type(self) Qgis.SymbolType[source]
Return type:

Qgis.SymbolType

virtual usedAttributes(self, context: QgsRenderContext) Set[str]

Returns the set of attributes referenced by the layer. This includes attributes required by any data defined properties associated with the layer.

Parameters:

context (QgsRenderContext)

Return type:

Set[str]

userFlags(self) Qgis.SymbolLayerUserFlags[source]

Returns user-controlled flags which control the symbol layer’s behavior.

See also

setUserFlags()

Added in version 3.34.

Return type:

Qgis.SymbolLayerUserFlags

virtual usesMapUnits(self) bool[source]

Returns True if the symbol layer has any components which use map unit based sizes.

Added in version 3.18.

Return type:

bool

virtual writeDxf(self, e: QgsDxfExport, mmMapUnitScaleFactor: float, layerName: str | None, context: QgsSymbolRenderContext, shift: QPointF | QPoint = QPointF(0, 0)) bool[source]

write as DXF

Parameters:
Return type:

bool