Class: QgsMapHitTest

class qgis.core.QgsMapHitTest(settings: QgsMapSettings, polygon: QgsGeometry = QgsGeometry(), layerFilterExpression: object = QgsMapHitTest.LayerFilterExpression())

Bases: sip.wrapper

Parameters:
  • settings – Map settings used to evaluate symbols
  • polygon – Polygon geometry to refine the hit test
  • layerFilterExpression – Expression string for each layer id to evaluate in order to refine the symbol selection

QgsMapHitTest(settings: QgsMapSettings, layerFilterExpression: object) Constructor version used with only expressions to filter symbols (no extent or polygon intersection)

QgsMapHitTest(QgsMapHitTest)

Class that runs a hit test with given map settings. Based on the hit test it returns which symbols will be visible on the map - this is useful for content based legend.

New in version 2.6: Enums

Methods

legendKeyVisible Tests whether a given legend key is visible for a specified layer.
run Runs the map hit test
symbolVisible Tests whether a symbol is visible for a specified layer.

Signals

Attributes

legendKeyVisible(self, ruleKey: str, layer: QgsVectorLayer) → bool

Tests whether a given legend key is visible for a specified layer.

Parameters:
  • ruleKey – legend rule key
  • layer – vector layer

See also

symbolVisible()

New in version 2.14.

run(self)

Runs the map hit test

symbolVisible(self, symbol: QgsSymbol, layer: QgsVectorLayer) → bool

Tests whether a symbol is visible for a specified layer.

Parameters:
  • symbol – symbol to find
  • layer – vector layer

New in version 2.12.