Class: QgsHighlight

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

Bases: PyQt5.QtCore.QObject, 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

childEvent()
color(self) → QColor

Returns the line/stroke color

New in version 3.4.

Return type

QColor

connectNotify()
contextMenuEvent()
customEvent()
disconnectNotify()
dragEnterEvent()
dragLeaveEvent()
dragMoveEvent()
dropEvent()
fillColor(self) → QColor

Returns the fill color

New in version 3.4.

Return type

QColor

focusInEvent()
focusOutEvent()
hoverEnterEvent()
hoverLeaveEvent()
hoverMoveEvent()
inputMethodEvent()
inputMethodQuery()
isSignalConnected()
itemChange()
keyPressEvent()
keyReleaseEvent()
layer(self) → QgsMapLayer

Returns the layer for which this highlight has been created.

Return type

QgsMapLayer

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

p (QPainter) –

prepareGeometryChange()
receivers()
sceneEvent()
sceneEventFilter()
sender()
senderSignalIndex()
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()
setWidth(self, width: int)

Set stroke width.

Note

Ignored in feature mode.

Parameters

width (int) –

timerEvent()
updateCanvas()
updateMicroFocus()
updatePosition(self)
updateRect(self)

recalculates needed rectangle

wheelEvent()
width(self) → int

Returns the stroke width

New in version 3.4.

Return type

int