Class: QgsNumericFormatRegistry

A registry which manages classes of QgsNumericFormat.

A reference to the QgsFieldFormatterRegistry can be obtained from QgsApplication.numericFormatRegistry().

Added in version 3.12.

class qgis.core.QgsNumericFormatRegistry[source]

Bases: object

__init__()

You should not normally need to create your own numeric format registry.

Use the one provided by :py:func:`QgsApplication.numericFormatRegistry()` instead.

__init__(a0: QgsNumericFormatRegistry)
Parameters:

a0 (QgsNumericFormatRegistry)

addFormat(self, format: QgsNumericFormat | None)[source]

Adds a new format to the registry.

Ownership is transferred to the registry.

Parameters:

format (Optional[QgsNumericFormat])

create(self, id: str | None, configuration: Dict[str, Any], context: QgsReadWriteContext) QgsNumericFormat | None[source]

Creates a new numeric format by id, using the supplied configuration. If there is no such id registered, a default QgsFallbackNumericFormat with a null id will be returned instead.

The caller takes ownership of the returned object.

Parameters:
Return type:

Optional[QgsNumericFormat]

createFromXml(self, element: QDomElement, context: QgsReadWriteContext) QgsNumericFormat | None[source]

Creates a new numeric format from an XML element. If there is no matching format ID registered, a default QgsFallbackNumericFormat will be returned instead.

The caller takes ownership of the returned object.

Parameters:
Return type:

Optional[QgsNumericFormat]

fallbackFormat(self) QgsNumericFormat | None[source]

Returns a basic numeric formatter which can be used to represent any number in an default manner.

The caller takes ownership of the returned object.

Return type:

Optional[QgsNumericFormat]

format(self, id: str | None) QgsNumericFormat | None[source]

Creates a new numeric format by id. If there is no such id registered, a default QgsFallbackNumericFormat with a null id will be returned instead.

The caller takes ownership of the returned object.

Parameters:

id (Optional[str])

Return type:

Optional[QgsNumericFormat]

formats(self) List[str][source]

Returns a list of the format IDs currently contained in the registry.

Return type:

List[str]

removeFormat(self, id: str | None)[source]

Removes the format with matching id from the registry.

Parameters:

id (Optional[str])

sortKey(self, id: str | None) int[source]

Returns the sorting key for the format with matching id.

Parameters:

id (Optional[str])

Return type:

int

visibleName(self, id: str | None) str[source]

Returns the translated, user-visible name for the format with matching id.

Parameters:

id (Optional[str])

Return type:

str