Class: QgsHighlight

class qgis.gui.QgsHighlight(mapCanvas: QgsMapCanvas, geom: QgsGeometry, layer: QgsMapLayer)

Bases: QgsMapCanvasItem

Constructor for QgsHighlight

Parameters

QgsHighlight(mapCanvas: QgsMapCanvas, feature: QgsFeature, layer: QgsVectorLayer) Constructor for highlighting True feature shape using feature attributes and renderer.

Parameters
  • mapCanvas – map canvas

  • feature

  • layer – vector layer

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()

.. autoautosummary:: qgis.gui.QgsHighlight
    :enums:
    :nosignatures:

.. autoautosummary:: qgis.gui.QgsHighlight
    :methods:
    :nosignatures:

.. autoautosummary:: qgis.gui.QgsHighlight
    :signals:
    :nosignatures:

.. autoautosummary:: qgis.gui.QgsHighlight
    :attributes:
buffer(self) → float

Returns the buffer

New in version 3.4.

Return type

float

color(self) → QColor

Returns the line/stroke color

New in version 3.4.

Return type

QColor

contextMenuEvent(self, QGraphicsSceneContextMenuEvent)
dragEnterEvent(self, QGraphicsSceneDragDropEvent)
dragLeaveEvent(self, QGraphicsSceneDragDropEvent)
dragMoveEvent(self, QGraphicsSceneDragDropEvent)
dropEvent(self, QGraphicsSceneDragDropEvent)
fillColor(self) → QColor

Returns the fill color

New in version 3.4.

Return type

QColor

focusInEvent(self, QFocusEvent)
focusOutEvent(self, QFocusEvent)
hoverEnterEvent(self, QGraphicsSceneHoverEvent)
hoverLeaveEvent(self, QGraphicsSceneHoverEvent)
hoverMoveEvent(self, QGraphicsSceneHoverEvent)
inputMethodEvent(self, QInputMethodEvent)
inputMethodQuery(self, Qt.InputMethodQuery) → Any
itemChange(self, QGraphicsItem.GraphicsItemChange, Any) → Any
keyPressEvent(self, QKeyEvent)
keyReleaseEvent(self, QKeyEvent)
layer(self)QgsMapLayer

Returns the layer for which this highlight has been created.

Return type

QgsMapLayer

mouseDoubleClickEvent(self, QGraphicsSceneMouseEvent)
mouseMoveEvent(self, QGraphicsSceneMouseEvent)
mousePressEvent(self, QGraphicsSceneMouseEvent)
mouseReleaseEvent(self, QGraphicsSceneMouseEvent)
paint(self, p: QPainter)
Parameters

p (QPainter) –

prepareGeometryChange(self)
sceneEvent(self, QEvent) → bool
sceneEventFilter(self, QGraphicsItem, QEvent) → bool
setBuffer(self, buffer: float)

Set line / stroke buffer in millimeters.

New in version 2.4.

Parameters

buffer (float) –

setColor(self, color: Union[QColor, Qt.GlobalColor, QGradient])

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. *

Parameters

color (Union[QColor) –

setFillColor(self, fillColor: Union[QColor, Qt.GlobalColor, QGradient])

Fill color for the highlight. Will be used for polygons and points.

New in version 2.4.

Parameters

fillColor (Union[QColor) –

setMinWidth(self, width: float)

Set minimum line / stroke width in millimeters.

New in version 2.4.

Parameters

width (float) –

setRenderContextVariables(self, p: QPainter, context: QgsRenderContext) → bool

Sets render context parameters

Parameters
  • p – painter for rendering

  • context – out: configured context

Returns

true in case of success

setWidth(self, width: int)

Set stroke width.

Note

Ignored in feature mode.

Parameters

width (int) –

updateCanvas(self)

schedules map canvas for repaint

updateMicroFocus(self)
updatePosition(self)
updateRect(self)

recalculates needed rectangle

wheelEvent(self, QGraphicsSceneWheelEvent)
width(self) → int

Returns the stroke width

New in version 3.4.

Return type

int