Class: QgsLineSymbol

class qgis.core.QgsLineSymbol

Bases: QgsSymbol

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

QgsLineSymbol(layers: Iterable[QgsSymbolLayer] = []) Constructor for QgsLineSymbol, with the specified list of initial symbol layers.

Ownership of the layers are transferred to the symbol.

Methods

clone

rtype:

QgsLineSymbol

cloneLayers

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

createSimple

Create a line symbol with one symbol layer: SimpleLine with specified properties.

dataDefinedWidth

Returns data defined width for whole symbol (including all symbol layers).

renderPolyline

Renders the symbol along the line joining points, using the given render context.

renderUsingLayer

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

renderVertexMarker

Render editing vertex marker at specified point

setDataDefinedWidth

Set data defined width for whole symbol (including all symbol layers).

setWidth

Sets the width for the whole line symbol.

setWidthUnit

Sets the width units for the whole symbol (including all symbol layers).

width

Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol layers in the symbol.

clone(self) QgsLineSymbol
Return type:

QgsLineSymbol

cloneLayers(self) List[QgsSymbolLayer]

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

createSimple(properties: Dict[str, Any]) QgsLineSymbol

Create a line symbol with one symbol layer: SimpleLine with specified properties. This is a convenience method for easier creation of line symbols.

Parameters:

properties (Dict[str) –

Return type:

QgsLineSymbol

dataDefinedWidth(self) QgsProperty

Returns data defined width for whole symbol (including all symbol layers).

Return type:

QgsProperty

Returns:

data defined width, or invalid property if size is not set at the line level. Caller takes responsibility for deleting the returned object.

New in version 3.0.

renderPolyline(self, points: QPolygonF, f: QgsFeature, context: QgsRenderContext, layer: int = -1, selected: bool = False)

Renders the symbol along the line joining points, using the given render context.

The f argument is used to pass the feature currently being rendered (when available).

If only a single symbol layer from the symbol should be rendered, it should be specified in the layer argument. A layer of -1 indicates that all symbol layers should be rendered.

If selected is True then the symbol will be drawn using the “selected feature” style and colors instead of the symbol’s normal style.

Parameters:
renderUsingLayer(self, layer: QgsSymbolLayer, context: QgsSymbolRenderContext, geometryType: QgsWkbTypes.GeometryType = QgsWkbTypes.GeometryType.UnknownGeometry, points: QPolygonF = None, rings: Iterable[QPolygonF] = [])

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.

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

Render editing vertex marker at specified point

New in version 2.16.

setDataDefinedWidth(self, property: QgsProperty)

Set data defined width for whole symbol (including all symbol layers).

New in version 3.0.

Parameters:

property (QgsProperty) –

setWidth(self, width: float)

Sets the width for the whole line symbol. Individual symbol layer sizes will be scaled to maintain their current relative size to the whole symbol size.

See also

width()

Parameters:

width (float) –

setWidthUnit(self, unit: QgsUnitTypes.RenderUnit)

Sets the width units for the whole symbol (including all symbol layers).

Parameters:

unit (QgsUnitTypes.RenderUnit) – size units

New in version 3.16.

width(self) float

Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol layers in the symbol.

Warning

This returned value is inaccurate if the symbol consists of multiple symbol layers with different width units. Use the overload accepting a QgsRenderContext argument instead for accurate sizes in this case.

See also

setWidth()

width(self, context: QgsRenderContext) -> float Returns the symbol width, in painter units. This is the maximum width of all marker symbol layers in the symbol.

This method returns an accurate width by calculating the actual rendered width of each symbol layer using the provided render context.

See also

setWidth()

New in version 3.4.5.

Return type:

float