Class: QgsSymbol

Abstract base class for all rendered symbols.

Note

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

The following methods must be implemented: clone()

Class Hierarchy

Inheritance diagram of qgis.core.QgsSymbol

Subclasses

QgsFillSymbol

A fill symbol type, for rendering Polygon and MultiPolygon geometries.

QgsLineSymbol

A line symbol type, for rendering LineString and MultiLineString geometries.

QgsMarkerSymbol

A marker symbol type, for rendering Point and MultiPoint geometries.

Enums

PreviewFlag

alias of SymbolPreviewFlag

Property

Data definable properties.

RenderHint

alias of SymbolRenderHint

ScaleMethod

Scale methods

SymbolType

Symbol types

Abstract Methods

clone

Returns a deep copy of this symbol.

Methods

animationSettings

Returns a reference to the symbol animation settings.

appendSymbolLayer

Appends a symbol layer at the end of the current symbol layer list.

asImage

Returns an image of the symbol at the specified size.

bigSymbolPreviewImage

bigSymbolPreviewImageV2

Returns a large (roughly 100x100 pixel) preview image for the symbol.

bufferSettings

Returns the symbol buffer settings, which control an optional "halo" effect around the symbol.

canCauseArtifactsBetweenAdjacentTiles

Returns True if the symbol 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.

changeSymbolLayer

Deletes the current layer at the specified index and replaces it with layer.

clipFeaturesToExtent

Returns whether features drawn by the symbol will be clipped to the render context's extent.

cloneLayers

Retrieve a cloned list of all layers that make up this symbol.

color

Returns the symbol's color.

copyCommonProperties

Copies common properties from an other symbol to this symbol.

dataDefinedProperties

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

deleteSymbolLayer

Removes and deletes the symbol layer at the specified index.

drawPreviewIcon

Draws an icon of the symbol that occupies an area given by size using the specified painter.

dump

Returns a string dump of the symbol's properties.

exportImage

Export the symbol as an image format, to the specified path and with the given size.

extentBuffer

Returns the symbol's extent buffer.

extentBufferSizeUnit

Returns the units for the buffer size.

flags

Returns flags for the symbol.

forceRHR

Returns True if polygon features drawn by the symbol will be reoriented to follow the standard right-hand-rule orientation, in which the area that is bounded by the polygon is to the right of the boundary.

hasDataDefinedProperties

Returns whether the symbol utilizes any data defined properties.

insertSymbolLayer

Inserts a symbol layer to specified index.

layer

mapUnitScale

Returns the map unit scale for the symbol.

opacity

Returns the opacity for the symbol.

outputUnit

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

propertyDefinitions

Returns the symbol property definitions.

renderFeature

Render a feature.

renderHints

Returns the rendering hint flags for the symbol.

renderUsingLayer

Renders a context using a particular symbol layer without passing in a geometry.

renderVertexMarker

Render editing vertex marker at specified point

setAnimationSettings

Sets a the symbol animation settings.

setBufferSettings

Sets a the symbol buffer settings, which control an optional "halo" effect around the symbol.

setClipFeaturesToExtent

Sets whether features drawn by the symbol should be clipped to the render context's extent.

setColor

Sets the color for the symbol.

setDataDefinedProperties

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

setDataDefinedProperty

Sets a data defined property for the symbol.

setExtentBuffer

Sets the symbol's extent buffer.

setExtentBufferSizeUnit

Sets the unit used for the extent buffer.

setFlags

Sets flags for the symbol.

setForceRHR

Sets whether polygon features drawn by the symbol should be reoriented to follow the standard right-hand-rule orientation, in which the area that is bounded by the polygon is to the right of the boundary.

setLayer

Sets the vector layer associated with the symbol.

setMapUnitScale

Sets the map unit scale for the symbol.

setOpacity

Sets the opacity for the symbol.

setOutputUnit

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

setRenderHints

Sets rendering hint flags for the symbol.

startFeatureRender

Called before symbol layers will be rendered for a particular feature.

startRender

Begins the rendering process for the symbol.

stopFeatureRender

Called after symbol layers have been rendered for a particular feature.

stopRender

Ends the rendering process.

symbolLayer

Returns the symbol layer at the specified index.

symbolLayerCount

Returns the total number of symbol layers contained in the symbol.

symbolLayers

Returns the list of symbol layers contained in the symbol.

symbolRenderContext

Returns the symbol render context.

takeSymbolLayer

Removes a symbol layer from the list and returns a pointer to it.

toSld

Converts the symbol to a SLD representation.

type

Returns the symbol's type.

usedAttributes

Returns a list of attributes required to render this feature.

usesMapUnits

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

Static Methods

defaultSymbol

Returns a new default symbol for the specified geometry type.

symbolTypeForGeometryType

Returns the default symbol type required for the specified geometry type.

symbolTypeToString

Returns a translated string version of the specified symbol type.

class qgis.core.QgsSymbol[source]

Bases: object

PreviewFlag

alias of SymbolPreviewFlag

PreviewFlags

alias of SymbolPreviewFlags

class Property(*values)

Bases: IntEnum

Data definable properties.

Added in version 3.18.

  • Opacity: Opacity

    Available as QgsSymbol.PropertyOpacity in older QGIS releases.

  • ExtentBuffer: Extent buffer

    Added in version 3.42.

RenderHint

alias of SymbolRenderHint

RenderHints

alias of SymbolRenderHints

class ScaleMethod(*values)

Bases: IntEnum

Scale methods

Added in version 3.20.

  • ScaleArea: Calculate scale by the area

  • ScaleDiameter: Calculate scale by the diameter

class SymbolPreviewFlags
class SymbolPreviewFlags(f: Qgis.SymbolPreviewFlags | Qgis.SymbolPreviewFlag)
class SymbolPreviewFlags(a0: Qgis.SymbolPreviewFlags)

Bases: object

class SymbolType(*values)

Bases: IntEnum

Symbol types

Added in version 3.20.

  • Marker: Marker symbol

  • Line: Line symbol

  • Fill: Fill symbol

  • Hybrid: Hybrid symbol

animationSettings(self) QgsSymbolAnimationSettings

Returns a reference to the symbol animation settings.

Added in version 3.26.

Return type:

QgsSymbolAnimationSettings

appendSymbolLayer(self, layer: QgsSymbolLayer | None) bool[source]

Appends a symbol layer at the end of the current symbol layer list. Ownership of layer is transferred to the symbol.

Return type:

bool

Returns:

True if the layer was successfully added, False if the layer is not compatible with the symbol’s type().

Parameters:

layer (Optional[QgsSymbolLayer])

asImage(self, size: QSize, customContext: QgsRenderContext | None = None) QImage[source]

Returns an image of the symbol at the specified size.

Optionally a custom render context may be given in order to ensure that the preview icon exactly matches the settings from that context.

See also

exportImage()

Parameters:
Return type:

QImage

bigSymbolPreviewImage(self, expressionContext: QgsExpressionContext | None = None, flags: int = unknown - type(Qgis.SymbolPreviewFlag.FlagIncludeCrosshairsForMarkerSymbols)) QImage[source]

Deprecated since version 3.40.

Use bigSymbolPreviewImageV2() instead.

Parameters:
  • expressionContext (Optional[QgsExpressionContext] = None)

  • flags (int = unknown-type(Qgis.SymbolPreviewFlag.FlagIncludeCrosshairsForMarkerSymbols))

Return type:

QImage

bigSymbolPreviewImageV2(self, expressionContext: QgsExpressionContext | None = None, flags: Qgis.SymbolPreviewFlags | Qgis.SymbolPreviewFlag = Qgis.SymbolPreviewFlag.FlagIncludeCrosshairsForMarkerSymbols, screen: QgsScreenProperties = QgsScreenProperties()) QImage

Returns a large (roughly 100x100 pixel) preview image for the symbol.

Parameters:
  • expressionContext (Optional[QgsExpressionContext] = None) – optional expression context, for evaluation of data defined symbol properties

  • flags (Union[Qgis.SymbolPreviewFlags, Qgis.SymbolPreviewFlag] = Qgis.SymbolPreviewFlag.FlagIncludeCrosshairsForMarkerSymbols) – optional flags to control how preview image is generated

  • screen (QgsScreenProperties = QgsScreenProperties()) – can be used to specify the destination screen properties for the icon. This allows the icon to be generated using the correct DPI and device pixel ratio for a target screen (since QGIS 3.32)

See also

asImage()

Return type:

QImage

bufferSettings(self) QgsSymbolBufferSettings | None[source]

Returns the symbol buffer settings, which control an optional “halo” effect around the symbol.

Will be None if no buffer settings have previously been set for the symbol.

Added in version 3.40.

Return type:

Optional[QgsSymbolBufferSettings]

canCauseArtifactsBetweenAdjacentTiles(self) bool[source]

Returns True if the symbol 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.

Internally this calls QgsSymbolLayer.canCauseArtifactsBetweenAdjacentTiles() for all symbol layers in the symbol and returns True if any of the layers returned True.

Added in version 3.18.

Return type:

bool

changeSymbolLayer(self, index: int, layer: QgsSymbolLayer | None) bool[source]

Deletes the current layer at the specified index and replaces it with layer. Ownership of layer is transferred to the symbol.

Returns False if layer is not compatible with the symbol’s type(), or True if the layer was successfully replaced.

Parameters:
Return type:

bool

clipFeaturesToExtent(self) bool[source]

Returns whether features drawn by the symbol will be clipped to the render context’s extent. If this option is enabled then features which are partially outside the extent will be clipped. This speeds up rendering of the feature, but may have undesirable side effects for certain symbol types.

Return type:

bool

Returns:

True if features will be clipped

abstract clone(self) QgsSymbol | None[source]

Returns a deep copy of this symbol.

Ownership is transferred to the caller.

Return type:

Optional[QgsSymbol]

cloneLayers(self) List[QgsSymbolLayer][source]

Retrieve a cloned list of all layers that make up this symbol. Ownership is transferred to the caller.

Return type:

List[QgsSymbolLayer]

color(self) QColor[source]

Returns the symbol’s color.

For multi-layer symbols, this method returns the color of the first unlocked symbol layer.

See also

setColor()

Return type:

QColor

copyCommonProperties(self, other: QgsSymbol | None)[source]

Copies common properties from an other symbol to this symbol.

Added in version 3.40.

Parameters:

other (Optional[QgsSymbol])

dataDefinedProperties(self) QgsPropertyCollection

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

See also

Property

Added in version 3.18.

Return type:

QgsPropertyCollection

static defaultSymbol(geomType: Qgis.GeometryType) QgsSymbol | None[source]

Returns a new default symbol for the specified geometry type.

The caller takes ownership of the returned object.

Parameters:

geomType (Qgis.GeometryType)

Return type:

Optional[QgsSymbol]

deleteSymbolLayer(self, index: int) bool[source]

Removes and deletes the symbol layer at the specified index.

Parameters:

index (int)

Return type:

bool

drawPreviewIcon(self, painter: QPainter | None, size: QSize, customContext: QgsRenderContext | None = None, selected: bool = False, expressionContext: QgsExpressionContext | None = None, patchShape: QgsLegendPatchShape | None = None, screen: QgsScreenProperties = QgsScreenProperties())[source]

Draws an icon of the symbol that occupies an area given by size using the specified painter.

Optionally a custom render context may be given in order to ensure that the preview icon exactly matches the settings from that context.

Parameters:
  • painter (Optional[QPainter]) – destination painter

  • size (QSize) – size of the icon

  • customContext (Optional[QgsRenderContext] = None) – the context in which the rendering happens

  • selected (bool = False) – set to True to render the symbol in a selected state (since QGIS 3.10)

  • expressionContext (Optional[QgsExpressionContext] = None) – optional custom expression context

  • patchShape (Optional[QgsLegendPatchShape] = None) – optional patch shape to use for symbol preview. If not specified a default shape will be used instead.

  • screen (QgsScreenProperties = QgsScreenProperties()) – can be used to specify the destination screen properties for the icon. This allows the icon to be generated using the correct DPI and device pixel ratio for the target screen (since QGIS 3.32)

See also

exportImage()

See also

asImage()

dump(self) str[source]

Returns a string dump of the symbol’s properties.

Return type:

str

exportImage(self, path: str | None, format: str | None, size: QSize)[source]

Export the symbol as an image format, to the specified path and with the given size.

If format is “SVG” then an SVG file will be created, otherwise a raster image of the specified format will be created.

See also

asImage()

Parameters:
  • path (Optional[str])

  • format (Optional[str])

  • size (QSize)

extentBuffer(self) float[source]

Returns the symbol’s extent buffer.

Units are retrieved via extentBufferSizeUnit().

Added in version 3.42.

Return type:

float

extentBufferSizeUnit(self) Qgis.RenderUnit[source]

Returns the units for the buffer size.

See also

extentBuffer()

Added in version 3.42.

Return type:

Qgis.RenderUnit

flags(self) Qgis.SymbolFlags[source]

Returns flags for the symbol.

See also

setFlags()

Added in version 3.20.

Return type:

Qgis.SymbolFlags

forceRHR(self) bool[source]

Returns True if polygon features drawn by the symbol will be reoriented to follow the standard right-hand-rule orientation, in which the area that is bounded by the polygon is to the right of the boundary. In particular, the exterior ring is oriented in a clockwise direction and the interior rings in a counter-clockwise direction.

See also

setForceRHR()

Added in version 3.6.

Return type:

bool

hasDataDefinedProperties(self) bool[source]

Returns whether the symbol utilizes any data defined properties.

Return type:

bool

insertSymbolLayer(self, index: int, layer: QgsSymbolLayer | None) bool[source]

Inserts a symbol layer to specified index. Ownership of layer is transferred to the symbol.

Parameters:
  • index (int) – The index at which the layer should be added

  • layer (Optional[QgsSymbolLayer]) – The symbol layer to add

Return type:

bool

Returns:

True if the layer is added, False if the index or the layer is bad

layer(self) QgsVectorLayer | None[source]

Deprecated since version 3.40.

Will be removed in QGIS 4.0.

Return type:

Optional[QgsVectorLayer]

mapUnitScale(self) QgsMapUnitScale[source]

Returns the map unit scale for the symbol.

If the symbol consists of multiple layers, the map unit scale is only returned if all layers have the same scale settings. If the settings differ, a default constructed map unit scale is returned.

Return type:

QgsMapUnitScale

opacity(self) float[source]

Returns the opacity for the symbol.

Return type:

float

Returns:

opacity value between 0 (fully transparent) and 1 (fully opaque)

See also

setOpacity()

outputUnit(self) Qgis.RenderUnit[source]

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

Return type:

Qgis.RenderUnit

Returns:

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

See also

setOutputUnit()

propertyDefinitions() Dict[int, QgsPropertyDefinition]

Returns the symbol property definitions.

Added in version 3.18.

Return type:

Dict[int, QgsPropertyDefinition]

renderFeature(self, feature: QgsFeature, context: QgsRenderContext, layer: int = -1, selected: bool = False, drawVertexMarker: bool = False, currentVertexMarkerType: Qgis.VertexMarkerType = Qgis.VertexMarkerType.SemiTransparentCircle, currentVertexMarkerSize: float = 0)[source]

Render a feature. Before calling this the startRender() method should be called to initialize the rendering process. After rendering all features stopRender() must be called.

Parameters:
  • feature (QgsFeature)

  • context (QgsRenderContext)

  • layer (int = -1)

  • selected (bool = False)

  • drawVertexMarker (bool = False)

  • currentVertexMarkerType (Qgis.VertexMarkerType = Qgis.VertexMarkerType.SemiTransparentCircle)

  • currentVertexMarkerSize (float = 0)

renderHints(self) Qgis.SymbolRenderHints[source]

Returns the rendering hint flags for the symbol.

See also

setRenderHints()

Return type:

Qgis.SymbolRenderHints

renderUsingLayer(self, layer: QgsSymbolLayer | None, context: QgsSymbolRenderContext, geometryType: Qgis.GeometryType = Qgis.GeometryType.Unknown, points: QPolygonF | None = None, rings: Iterable[QPolygonF] | None = [])[source]

Renders a context using a particular symbol layer without passing in a geometry. This is used as fallback, if the symbol being rendered is not compatible with the specified layer. In such a case, this method can be called and will call the layer’s rendering method anyway but the geometry passed to the layer will be empty. This is required for layers that generate their own geometry from other information in the rendering context.

Since QGIS 3.22, the optional geometryType, points and rings arguments can specify the original geometry type, points and rings in which are being rendered by the parent symbol.

Parameters:
  • layer (Optional[QgsSymbolLayer])

  • context (QgsSymbolRenderContext)

  • geometryType (Qgis.GeometryType = Qgis.GeometryType.Unknown)

  • points (Optional[QPolygonF] = None)

  • rings (Optional[Iterable[QPolygonF]] = [])

renderVertexMarker(self, pt: QPointF | QPoint, context: QgsRenderContext, currentVertexMarkerType: Qgis.VertexMarkerType, currentVertexMarkerSize: float)[source]

Render editing vertex marker at specified point

Parameters:
setAnimationSettings(self, settings: QgsSymbolAnimationSettings)[source]

Sets a the symbol animation settings.

Added in version 3.26.

Parameters:

settings (QgsSymbolAnimationSettings)

setBufferSettings(self, settings: QgsSymbolBufferSettings | None)[source]

Sets a the symbol buffer settings, which control an optional “halo” effect around the symbol.

Ownership is transferred to the symbol.

See also

bufferSettings()

Added in version 3.40.

Parameters:

settings (Optional[QgsSymbolBufferSettings])

setClipFeaturesToExtent(self, clipFeaturesToExtent: bool)[source]

Sets whether features drawn by the symbol should be clipped to the render context’s extent. If this option is enabled then features which are partially outside the extent will be clipped. This speeds up rendering of the feature, but may have undesirable side effects for certain symbol types.

Parameters:

clipFeaturesToExtent (bool) – set to True to enable clipping (defaults to True)

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

Sets the color for the symbol.

Calling this method sets the color for each individual symbol layer contained within the symbol to color.

Locked symbol layers are skipped and are left unchanged.

See also

color()

Parameters:

color (Union[QColor, Qt.GlobalColor])

setDataDefinedProperties(self, collection: QgsPropertyCollection)[source]

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

Parameters:

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

Added in version 3.18.

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

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

See also

Property

Added in version 3.18.

Parameters:
setExtentBuffer(self, extentBuffer: float)[source]

Sets the symbol’s extent buffer.

Units are set via setExtentBufferSizeUnit().

Parameters:

extentBuffer (float) – buffer distance.

See also

extentBuffer()

Note

Negative values are not supported and will be changed to 0.

Added in version 3.42.

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

Sets the unit used for the extent buffer.

Added in version 3.42.

Parameters:

unit (Qgis.RenderUnit)

setFlags(self, flags: Qgis.SymbolFlags | Qgis.SymbolFlag)[source]

Sets flags for the symbol.

See also

flags()

Added in version 3.320.

Parameters:

flags (Union[Qgis.SymbolFlags, Qgis.SymbolFlag])

setForceRHR(self, force: bool)[source]

Sets whether polygon features drawn by the symbol should be reoriented to follow the standard right-hand-rule orientation, in which the area that is bounded by the polygon is to the right of the boundary. In particular, the exterior ring is oriented in a clockwise direction and the interior rings in a counter-clockwise direction.

See also

forceRHR()

Added in version 3.6.

Parameters:

force (bool)

setLayer(self, layer: QgsVectorLayer | None)[source]

Sets the vector layer associated with the symbol.

Note

the layer will be None after stopRender

Deprecated since version 3.40: Will be removed in QGIS 4.0.

Parameters:

layer (Optional[QgsVectorLayer])

setMapUnitScale(self, scale: QgsMapUnitScale)[source]

Sets the map unit scale for the symbol.

Calling this method sets the scale for all symbol layers contained within the symbol.

See also

mapUnitScale()

Parameters:

scale (QgsMapUnitScale)

setOpacity(self, opacity: float)[source]

Sets the opacity for the symbol.

Parameters:

opacity (float) – opacity value between 0 (fully transparent) and 1 (fully opaque)

See also

opacity()

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

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

Parameters:

unit (Qgis.RenderUnit) – output units

See also

outputUnit()

setRenderHints(self, hints: Qgis.SymbolRenderHints | Qgis.SymbolRenderHint)[source]

Sets rendering hint flags for the symbol.

See also

renderHints()

Parameters:

hints (Union[Qgis.SymbolRenderHints, Qgis.SymbolRenderHint])

startFeatureRender(self, feature: QgsFeature, context: QgsRenderContext, layer: int = -1)[source]

Called before symbol layers 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).

Internally, this notifies all symbol layers which will be used via a call to QgsSymbolLayer.startFeatureRender().

Added in version 3.20.

Parameters:
startRender(self, context: QgsRenderContext, fields: QgsFields = QgsFields())[source]

Begins the rendering process for the symbol. This must be called before renderFeature(), and should be followed by a call to stopRender().

Parameters:
  • context (QgsRenderContext) – render context which symbol will be drawn using

  • fields (QgsFields = QgsFields()) – fields for features to be rendered (usually the associated vector layer’s fields). Required for correct calculation of data defined overrides.

See also

stopRender()

stopFeatureRender(self, feature: QgsFeature, context: QgsRenderContext, layer: int = -1)[source]

Called after symbol layers have been rendered for a particular feature.

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

Internally, this notifies all symbol layers which were used via a call to QgsSymbolLayer.stopFeatureRender().

Added in version 3.20.

Parameters:
stopRender(self, context: QgsRenderContext)[source]

Ends the rendering process. This should be called after rendering all desired features.

Parameters:

context (QgsRenderContext) – render context, must match the context specified when startRender() was called.

See also

startRender()

symbolLayer(self, layer: int) QgsSymbolLayer[source]

Returns the symbol layer at the specified index.

Raises:

IndexError – if no layer with the specified index exists.

See also

symbolLayers()

Parameters:

layer (int)

Return type:

QgsSymbolLayer

symbolLayerCount(self) int[source]

Returns the total number of symbol layers contained in the symbol.

Return type:

int

Returns:

count of symbol layers

See also

symbolLayers()

See also

symbolLayer()

symbolLayers(self) List[QgsSymbolLayer][source]

Returns the list of symbol layers contained in the symbol.

Return type:

List[QgsSymbolLayer]

Returns:

symbol layers list

See also

symbolLayer()

symbolRenderContext(self) QgsSymbolRenderContext | None[source]

Returns the symbol render context. Only valid between startRender and stopRender calls.

Return type:

Optional[QgsSymbolRenderContext]

Returns:

The symbol render context

static symbolTypeForGeometryType(type: Qgis.GeometryType) Qgis.SymbolType[source]

Returns the default symbol type required for the specified geometry type.

Added in version 3.20.

Parameters:

type (Qgis.GeometryType)

Return type:

Qgis.SymbolType

static symbolTypeToString(type: Qgis.SymbolType) str[source]

Returns a translated string version of the specified symbol type.

Added in version 3.20.

Parameters:

type (Qgis.SymbolType)

Return type:

str

takeSymbolLayer(self, index: int) QgsSymbolLayer | None[source]

Removes a symbol layer from the list and returns a pointer to it. Ownership of the layer is handed to the caller.

Parameters:

index (int) – The index of the layer to remove

Return type:

Optional[QgsSymbolLayer]

Returns:

A pointer to the removed layer

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

Converts the symbol to a SLD representation.

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

Parameters:
  • doc (QDomDocument)

  • element (QDomElement)

  • props (Dict[str, Any])

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

Converts the symbol to a SLD representation.

Returns True if the symbol was successfully converted.

Added in version 3.44.

Parameters:
Return type:

bool

type(self) Qgis.SymbolType[source]

Returns the symbol’s type.

Return type:

Qgis.SymbolType

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

Returns a list of attributes required to render this feature. This should include any attributes required by the symbology including the ones required by expressions.

Parameters:

context (QgsRenderContext)

Return type:

Set[str]

usesMapUnits(self) bool[source]

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

Added in version 3.18.

Return type:

bool