Class: QgsLineSymbol¶
A line symbol type, for rendering LineString and MultiLineString geometries.
Class Hierarchy¶
Base classes¶
Abstract base class for all rendered symbols. |
- class qgis.core.QgsLineSymbol[source]¶
Bases:
QgsSymbol- __init__(layers: Iterable[QgsSymbolLayer] = [])
Constructor for QgsLineSymbol, with the specified list of initial symbol
layers.Ownership of the
layersare transferred to the symbol.- Parameters:
layers (Iterable[QgsSymbolLayer] = [])
- static createSimple(properties: Dict[str, Any]) QgsLineSymbol | None¶
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, Any])
- Return type:
Optional[QgsLineSymbol]
- dataDefinedWidth(self) QgsProperty[source]¶
Returns data defined width for whole symbol (including all symbol layers).
- Return type:
- Returns:
data defined width, or invalid property if size is not set at the line level. Caller takes responsibility for deleting the returned object.
See also
- renderPolyline(self, points: QPolygonF, f: QgsFeature | None, context: QgsRenderContext, layer: int = -1, selected: bool = False)[source]¶
Renders the symbol along the line joining
points, using the given rendercontext.The
fargument 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
layerargument. Alayerof -1 indicates that all symbol layers should be rendered.If
selectedisTruethen the symbol will be drawn using the “selected feature” style and colors instead of the symbol’s normal style.- Parameters:
points (QPolygonF)
f (Optional[QgsFeature])
context (QgsRenderContext)
layer (int = -1)
selected (bool = False)
- setDataDefinedWidth(self, property: QgsProperty)[source]¶
Set data defined width for whole symbol (including all symbol layers).
See also
- Parameters:
property (QgsProperty)
- setWidth(self, width: float)[source]¶
Sets the
widthfor the whole line symbol. Individual symbol layer sizes will be scaled to maintain their current relative size to the whole symbol size.See also
- Parameters:
width (float)
- setWidthUnit(self, unit: Qgis.RenderUnit)[source]¶
Sets the width units for the whole symbol (including all symbol layers).
- Parameters:
unit (Qgis.RenderUnit) – size units
Added in version 3.16.
- width(self) float[source]¶
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
QgsRenderContextargument instead for accurate sizes in this case.See also
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
Added in version 3.4.5.
- Return type:
float