Class: QgsValueRelationFieldFormatter

Field formatter for a value relation field.

A value relation field formatter looks up the values from features on another layer.

Class Hierarchy

Inheritance diagram of qgis.core.QgsValueRelationFieldFormatter

Base classes

QgsFieldFormatter

A field formatter helps to handle and display values for a field.

class qgis.core.QgsValueRelationFieldFormatter[source]

Bases: QgsFieldFormatter

__init__()

Constructor for QgsValueRelationFieldFormatter.

__init__(a0: QgsValueRelationFieldFormatter)
Parameters:

a0 (QgsValueRelationFieldFormatter)

class ValueRelationItem(key: Any, value: str | None, description: str | None = '', group: Any = None)

Bases: object

Constructor for ValueRelationItem

QgsValueRelationFieldFormatter.ValueRelationItem()

QgsValueRelationFieldFormatter.ValueRelationItem(a0: QgsValueRelationFieldFormatter.ValueRelationItem)

description
group: object
key
value
virtual createCache(self, layer: QgsVectorLayer | None, fieldIndex: int, config: Dict[str, Any]) Any[source]

Create a cache for a value relation field. This can be used to keep the value map in the local memory if doing multiple lookups in a loop.

Parameters:
  • config (Dict[str, Any]) – The widget configuration

  • formFeature (QgsFeature = QgsFeature()) – The feature currently being edited with current attribute values

  • parentFormFeature (QgsFeature = QgsFeature()) – For embedded forms only, the feature currently being edited in the parent form with current attribute values

Return type:

List[QgsValueRelationFieldFormatter.ValueRelationItem]

Returns:

A kvp list of values for the widget

static expressionFormAttributes(expression: str | None) Set[str]

Returns a list of attributes required by the form context expression

Parameters:

expression (Optional[str]) – Form filter expression

Return type:

Set[str]

Returns:

list of attributes required by the expression

Added in version 3.2.

static expressionFormVariables(expression: str | None) Set[str]

Returns a list of variables required by the form context expression

Parameters:

expression (Optional[str]) – Form filter expression

Return type:

Set[str]

Returns:

list of variables required by the expression

Added in version 3.2.

static expressionIsUsable(expression: str | None, feature: QgsFeature, parentFeature: QgsFeature = QgsFeature()) bool[source]

Check whether the feature has all values required by the expression, optionally checks for parentFeature

Return type:

bool

Returns:

True if the expression can be used

Added in version 3.2.

Parameters:
static expressionParentFormAttributes(expression: str | None) Set[str]

Returns a list of attributes required by the parent form’s form context expression

Parameters:

expression (Optional[str]) – Form filter expression

Return type:

Set[str]

Returns:

list of parent attributes required by the expression

Added in version 3.14.

static expressionParentFormVariables(expression: str | None) Set[str]

Returns a list of variables required by the parent form’s form context expression

Parameters:

expression (Optional[str]) – Form filter expression

Return type:

Set[str]

Returns:

list of parent variables required by the expression

Added in version 3.14.

static expressionRequiresFormScope(expression: str | None) bool[source]

Check if the expression requires a form scope (i.e. if it uses fields or geometry of the currently edited feature).

Parameters:

expression (Optional[str]) – The widget’s filter expression

Return type:

bool

Returns:

True if the expression requires a form scope

Added in version 3.2.

static expressionRequiresParentFormScope(expression: str | None) bool[source]

Check if the expression requires a parent form scope (i.e. if it uses fields or geometry of the parent form’s currently edited feature).

Parameters:

expression (Optional[str]) – The widget’s filter expression

Return type:

bool

Returns:

True if the expression requires a parent form scope

Added in version 3.14.

static resolveLayer(config: Dict[str, Any], project: QgsProject | None) QgsVectorLayer | None[source]

Returns the (possibly None) layer from the widget’s config and project

Added in version 3.8.

Parameters:
Return type:

Optional[QgsVectorLayer]

static valueToStringList(value: Any) List[str][source]

Utility to convert a list or a string representation of an (hstore style: {1,2…}) list in value to a string list

Added in version 3.2.

Parameters:

value (Any)

Return type:

List[str]