Class: QgsHighlight¶
A class for highlight features on the map.
The QgsHighlight
class provides a transparent overlay canvas
item for highlighting features or geometries on a map canvas.
color = QColor(Qt.red)
highlight = QgsHighlight(mapCanvas, feature, layer)
highlight.setColor(color)
color.setAlpha(50)
highlight.setFillColor(color)
highlight.show()
Class Hierarchy¶
Base classes¶
An abstract class for items that can be placed on the map canvas. |
|
Methods
Applies the default style from the user settings to the highlight. |
|
Returns the line/stroke buffer size (in millimeters) |
|
Returns the line/stroke color |
|
Returns the fill color |
|
Returns the layer for which this highlight has been created. |
|
Sets the line/stroke buffer size (in millimeters). |
|
Set line/stroke to color, polygon fill to color with alpha = 63. |
|
Fill color for the highlight. |
|
Sets the minimum line/stroke width (in millimeters). |
|
Set stroke width. |
|
recalculates needed rectangle |
|
Returns the stroke width |
- class qgis.gui.QgsHighlight[source]¶
Bases:
QgsMapCanvasItem
- __init__(mapCanvas: QgsMapCanvas | None, geom: QgsGeometry, layer: QgsMapLayer | None)
Constructor for QgsHighlight
- Parameters:
mapCanvas (Optional[QgsMapCanvas]) – associated map canvas
geom (QgsGeometry) – initial geometry of highlight
layer (Optional[QgsMapLayer]) – associated map layer
- __init__(mapCanvas: QgsMapCanvas | None, feature: QgsFeature, layer: QgsVectorLayer | None)
Constructor for highlighting
True
feature shape using feature attributes and renderer.- Parameters:
mapCanvas (Optional[QgsMapCanvas]) – map canvas
feature (QgsFeature)
layer (Optional[QgsVectorLayer]) – vector layer
- applyDefaultStyle(self)[source]¶
Applies the default style from the user settings to the highlight.
Added in version 3.30.
- buffer(self) float [source]¶
Returns the line/stroke buffer size (in millimeters)
See also
Added in version 3.4.
- Return type:
float
- color(self) QColor [source]¶
Returns the line/stroke color
Added in version 3.4.
- Return type:
QColor
- layer(self) QgsMapLayer | None [source]¶
Returns the layer for which this highlight has been created.
- Return type:
Optional[QgsMapLayer]
- setBuffer(self, buffer: float)[source]¶
Sets the line/stroke buffer size (in millimeters).
See also
- Parameters:
buffer (float)
- setColor(self, color: QColor | Qt.GlobalColor)[source]¶
Set line/stroke to color, polygon fill to color with alpha = 63. This is legacy function, use
setFillColor()
aftersetColor()
if different fill color is required.- Parameters:
color (Union[QColor, Qt.GlobalColor])
- setFillColor(self, fillColor: QColor | Qt.GlobalColor)[source]¶
Fill color for the highlight. Will be used for polygons and points.
- Parameters:
fillColor (Union[QColor, Qt.GlobalColor])
- setMinWidth(self, width: float)[source]¶
Sets the minimum line/stroke width (in millimeters).
- Parameters:
width (float)