Class: QgsNumericFormat

class qgis.core.QgsNumericFormat

Bases: sip.wrapper

Default constructor

QgsNumericFormat(QgsNumericFormat)

A numeric formatter allows for formatting a numeric value for display, using a variety of different formatting techniques (e.g. as scientific notation, currency values, percentage values, etc)

This is an abstract base class and will always need to be subclassed.

Methods

clone

Clones the format, returning a new object.

configuration

Returns the current configuration of the formatter.

create

Creates a new copy of the format, using the supplied configuration.

formatDouble

Returns a formatted string representation of a numeric double value.

id

Returns a unique id for this numeric format.

sortKey

Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists.

suggestSampleValue

Returns a suggested sample value which nicely represents the current format configuration.

visibleName

Returns the translated, user-visible name for this format.

writeXml

Writes the format to an XML element.

clone(self)QgsNumericFormat

Clones the format, returning a new object.

The caller takes ownership of the returned object.

Return type

QgsNumericFormat

configuration(self, context: QgsReadWriteContext)Dict[str, Any]

Returns the current configuration of the formatter. This value can be used in a call to create() in order to recreate this formatter in its current state.

Parameters

context (QgsReadWriteContext) –

Return type

Dict[str, Any]

create(self, configuration: Dict[str, Any], context: QgsReadWriteContext)QgsNumericFormat

Creates a new copy of the format, using the supplied configuration.

The caller takes ownership of the returned object.

Parameters
Return type

QgsNumericFormat

formatDouble(self, value: float, context: QgsNumericFormatContext)str

Returns a formatted string representation of a numeric double value.

Parameters
Return type

str

id(self)str

Returns a unique id for this numeric format.

This id is used to identify this numeric format in the registry with QgsNumericFormatRegistry.format().

Return type

str

sortKey(self)int

Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists.

Generally, subclasses should return QgsNumericFormat.sortKey() as their sorting key.

Return type

int

suggestSampleValue(self)float

Returns a suggested sample value which nicely represents the current format configuration.

Return type

float

visibleName(self)str

Returns the translated, user-visible name for this format.

Return type

str

writeXml(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext)

Writes the format to an XML element.

Parameters