Class: qgsfunction

class qgis.core.qgsfunction

Decorator function used to define a user expression function.

Parameters
  • args – Number of parameters, set to ‘auto’ to accept a variable length of parameters.

  • group – The expression group to which this expression should be added.

  • **kwargs – See below

Keyword Arguments
  • referenced_columns (list) – An array of field names on which this expression works. Can be set to [QgsFeatureRequest.ALL_ATTRIBUTES]. By default empty.

  • usesgeometry (bool) – Defines if this expression requires the geometry. By default False.

  • handlesnull (bool) – Defines if this expression has custom handling for NULL values. If False, the result will always be NULL as soon as any parameter is NULL. False by default.

Example:

@qgsfunction(2, ‘test’): def add(values, feature, parent):

pass

Will create and register a function in QgsExpression called ‘add’ in the ‘test’ group that takes two arguments.

or not using feature and parent:

Example:

@qgsfunction(2, ‘test’): def add(values, *args):

pass

Enums

Methods

Signals

Attributes