QgsHighlight class
A class for highlight features on the map.
Contents
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()
Base classes
- class QgsMapCanvasItem
- An abstract class for items that can be placed on the map canvas.
Constructors, destructors, conversion operators
- QgsHighlight(QgsMapCanvas* mapCanvas, const QgsGeometry& geom, QgsMapLayer* layer)
- Constructor for QgsHighlight.
- QgsHighlight(QgsMapCanvas* mapCanvas, const QgsFeature& feature, QgsVectorLayer* layer)
- Constructor for highlighting true feature shape using feature attributes and renderer.
Public functions
- auto buffer() const -> double
- Returns the buffer.
- auto color() const -> QColor
- Returns the line/stroke color.
- auto fillColor() const -> QColor
- Returns the fill color.
- auto layer() const -> QgsMapLayer*
- Returns the layer for which this highlight has been created.
- void setBuffer(double buffer)
- Set line / stroke buffer in millimeters.
- void setColor(const QColor& color)
- Set line/stroke to color, polygon fill to color with alpha = 63.
- void setFillColor(const QColor& fillColor)
- Fill color for the highlight.
- void setMinWidth(double width)
- Set minimum line / stroke width in millimeters.
- void setWidth(int width)
- Set stroke width.
- void updatePosition() override
- called on changed extent or resize event to update position of the item
- auto width() const -> int
- Returns the stroke width.
Protected functions
- void paint(QPainter* painter) override
- function to be implemented by derived classes
- void updateRect()
- recalculates needed rectangle
Function documentation
QgsHighlight:: QgsHighlight(QgsMapCanvas* mapCanvas,
const QgsGeometry& geom,
QgsMapLayer* layer)
Constructor for QgsHighlight.
| Parameters | |
|---|---|
| mapCanvas | associated map canvas |
| geom | initial geometry of highlight |
| layer | associated map layer |
QgsHighlight:: QgsHighlight(QgsMapCanvas* mapCanvas,
const QgsFeature& feature,
QgsVectorLayer* layer)
Constructor for highlighting true feature shape using feature attributes and renderer.
| Parameters | |
|---|---|
| mapCanvas | map canvas |
| feature | |
| layer | vector layer |
double QgsHighlight:: buffer() const
Returns the buffer.
QColor QgsHighlight:: color() const
Returns the line/stroke color.
QColor QgsHighlight:: fillColor() const
Returns the fill color.
void QgsHighlight:: setBuffer(double buffer)
Set line / stroke buffer in millimeters.
void QgsHighlight:: setColor(const QColor& color)
Set line/stroke to color, polygon fill to color with alpha = 63.
This is legacy function, use setFillColor() after setColor() if different fill color is required.
void QgsHighlight:: setFillColor(const QColor& fillColor)
Fill color for the highlight.
Will be used for polygons and points.
void QgsHighlight:: setMinWidth(double width)
Set minimum line / stroke width in millimeters.
void QgsHighlight:: setWidth(int width)
Set stroke width.
int QgsHighlight:: width() const
Returns the stroke width.