Class: QgsRenderedFeatureHandlerInterface

An interface for classes which provide custom handlers for features rendered as part of a map render job.

QgsRenderedFeatureHandlerInterface objects are registered in the QgsMapSettings objects used to construct map render jobs. During the rendering operation, the handleRenderedFeature() method will be called once for every rendered feature, allowing the handler to perform some custom task based on the provided information.

They can be used for custom tasks which operate on a set of rendered features, such as creating spatial indexes of the location and rendered symbology bounding box of all features rendered on a map.

Added in version 3.10.

Note

This is an abstract class, with methods which must be implemented by a subclass.

The following methods must be implemented: handleRenderedFeature()

Abstract Methods

handleRenderedFeature

Called whenever a feature is rendered during a map render job.

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsRenderedFeatureHandlerInterface. See the FAQ for more details.

usedAttributes

Returns a list of attributes required by this handler, for the specified layer.

class qgis.core.QgsRenderedFeatureHandlerInterface[source]

Bases: object

class RenderedFeatureContext(renderContext: QgsRenderContext)

Bases: object

Constructor for RenderedFeatureContext.

Parameters:

renderContext – The render context which was used while rendering feature.

QgsRenderedFeatureHandlerInterface.RenderedFeatureContext(a0: QgsRenderedFeatureHandlerInterface.RenderedFeatureContext)

The render context which was used while rendering feature.

renderContext
abstract handleRenderedFeature(self, feature: QgsFeature, renderedBounds: QgsGeometry, context: QgsRenderedFeatureHandlerInterface.RenderedFeatureContext)[source]

Called whenever a feature is rendered during a map render job.

The renderedBounds argument specifies the (approximate) bounds of the rendered feature’s symbology. E.g. for point geometry features, this will be the bounding box of the marker symbol used to symbolize the point. renderedBounds geometries are specified in painter units (not map units).

Warning

This method may be called from many different threads (for multi-threaded map render operations), and accordingly care must be taken to ensure that handleRenderedFeature() implementations are appropriately thread safe.

The context argument is used to provide additional context relating to the rendering of a feature.

Parameters:
virtual usedAttributes(self, layer: QgsVectorLayer | None, context: QgsRenderContext) Set[str]

Returns a list of attributes required by this handler, for the specified layer. Attributes not listed in here may not be requested from the provider at rendering time.

Parameters:
Return type:

Set[str]