Subgroup: other

Class: QgsHighlight

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

Bases: qgis._gui.QgsMapCanvasItem

Constructor for QgsHighlight

Parameters:
  • mapCanvas – associated map canvas
  • geom – initial geometry of highlight
  • layer – associated map layer

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

.. rubric:: Methods

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

.. rubric:: Signals

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

.. rubric:: Attributes

.. autoautosummary:: qgis.gui.QgsHighlight
    :attributes:
contextMenuEvent()
dragEnterEvent()
dragLeaveEvent()
dragMoveEvent()
dropEvent()
focusInEvent()
focusOutEvent()
hoverEnterEvent()
hoverLeaveEvent()
hoverMoveEvent()
inputMethodEvent()
inputMethodQuery()
itemChange()
keyPressEvent()
keyReleaseEvent()
layer(self) → QgsMapLayer

Returns the layer for which this highlight has been created.

mouseDoubleClickEvent()
mouseMoveEvent()
mousePressEvent()
mouseReleaseEvent()
paint(self, p: QPainter)
prepareGeometryChange()
sceneEvent()
sceneEventFilter()
setBuffer(self, buffer: float)

Set line / stroke buffer in millimeters.

New in version 2.4.

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

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.

setMinWidth(self, width: float)

Set minimum line / stroke width in millimeters.

New in version 2.4.

setRenderContextVariables()
setWidth(self, width: int)

Set stroke width.

Note

Ignored in feature mode.

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

recalculates needed rectangle

wheelEvent()