Class: register_function

class qgis.core.register_function(function, arg_count, group, usesgeometry=False, referenced_columns=['#!allattributes!#'], handlesnull=False, **kwargs)

Register a Python function to be used as a expression function.

Functions should take (values, feature, parent) as args:

Example:
def myfunc(values, feature, parent):

pass

They can also shortcut naming feature and parent args by using *args if they are not needed in the function.

Example:
def myfunc(values, *args):

pass

Functions should return a value compatible with QVariant

Eval errors can be raised using parent.setEvalErrorString(“Error message”)

Parameters:
  • function

  • arg_count

  • group

  • usesgeometry

  • handlesnull – Needs to be set to True if this function does not always return NULL if any parameter is NULL. Default False.

Returns: