QgsRelationReferenceFieldFormatter class

Field formatter for a relation reference field.

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

Base classes

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

Constructors, destructors, conversion operators

QgsRelationReferenceFieldFormatter() defaulted
Default constructor of field formatter for a relation reference field.

Public functions

auto id() const -> QString override
Returns a unique id for this field formatter.
auto representValue(QgsVectorLayer* layer, int fieldIndex, const QVariantMap& config, const QVariant& cache, const QVariant& value) const -> QString override
Create a pretty String representation of the value.
auto sortValue(QgsVectorLayer* layer, int fieldIndex, const QVariantMap& config, const QVariant& cache, const QVariant& value) const -> QVariant override
If the default sort order should be overwritten for this widget, you can transform the value in here.

Function documentation

QString QgsRelationReferenceFieldFormatter::id() const override

Returns a unique id for this field formatter.

This id will later be used to identify this field formatter in the registry with QgsFieldFormatterRegistry::fieldFormatter().

This id matches the id of a QgsEditorWidgetFactory.

QString QgsRelationReferenceFieldFormatter::representValue(QgsVectorLayer* layer, int fieldIndex, const QVariantMap& config, const QVariant& cache, const QVariant& value) const override

Create a pretty String representation of the value.

Returns By default the string representation of the provided value as implied by the field definition is returned.

QVariant QgsRelationReferenceFieldFormatter::sortValue(QgsVectorLayer* layer, int fieldIndex, const QVariantMap& config, const QVariant& cache, const QVariant& value) const override

If the default sort order should be overwritten for this widget, you can transform the value in here.

Returns an unmodified value by default.