QgsKeyValueFieldFormatter class

Field formatter for a key value field.

This represents a list type value. Values will be represented as a colon-delimited and comma-separated list.

E.g. "color: yellow, amount: 5"

Base classes

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

Constructors, destructors, conversion operators

QgsKeyValueFieldFormatter() defaulted
Default constructor of field formatter for a key value 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.

Function documentation

QString QgsKeyValueFieldFormatter::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 QgsKeyValueFieldFormatter::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.