Class: QgsNumericFormatRegistry¶
- class qgis.core.QgsNumericFormatRegistry¶
Bases:
sip.wrapper
You should not normally need to create your own numeric format registry.
Use the one provided by :py:func:`QgsApplication.numericFormatRegistry()` instead.
QgsNumericFormatRegistry(
QgsNumericFormatRegistry
)The
QgsNumericFormatRegistry
manages registered classes ofQgsNumericFormat
.A reference to the
QgsFieldFormatterRegistry
can be obtained fromQgsApplication.numericFormatRegistry()
.Methods
Adds a new
format
to the registry.Creates a new numeric format by
id
, using the suppliedconfiguration
.Creates a new numeric format from an XML
element
.Returns a basic numeric formatter which can be used to represent any number in an default manner.
Creates a new numeric format by
id
.Returns a list of the format IDs currently contained in the registry.
Removes the format with matching
id
from the registry.Returns the sorting key for the format with matching
id
.Returns the translated, user-visible name for the format with matching
id
.- addFormat(self, format: QgsNumericFormat)¶
Adds a new
format
to the registry.Ownership is transferred to the registry.
- Parameters
format (QgsNumericFormat) –
- create(self, id: str, configuration: Dict[str, Any], context: QgsReadWriteContext) → QgsNumericFormat¶
Creates a new numeric format by
id
, using the suppliedconfiguration
. If there is no suchid
registered, a defaultQgsFallbackNumericFormat
with a null id will be returned instead.The caller takes ownership of the returned object.
- Parameters
id (str) –
configuration (Dict[str) –
context (QgsReadWriteContext) –
- Return type
- createFromXml(self, element: QDomElement, context: QgsReadWriteContext) → QgsNumericFormat¶
Creates a new numeric format from an XML
element
. If there is no matching format ID registered, a defaultQgsFallbackNumericFormat
will be returned instead.The caller takes ownership of the returned object.
- Parameters
element (QDomElement) –
context (QgsReadWriteContext) –
- Return type
- fallbackFormat(self) → QgsNumericFormat¶
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
- format(self, id: str) → QgsNumericFormat¶
Creates a new numeric format by
id
. If there is no suchid
registered, a defaultQgsFallbackNumericFormat
with a null id will be returned instead.The caller takes ownership of the returned object.
- Parameters
id (str) –
- Return type
- formats(self) → List[str]¶
Returns a list of the format IDs currently contained in the registry.
- Return type
List[str]
- removeFormat(self, id: str)¶
Removes the format with matching
id
from the registry.- Parameters
id (str) –
- sortKey(self, id: str) → int¶
Returns the sorting key for the format with matching
id
.- Parameters
id (str) –
- Return type
int
- visibleName(self, id: str) → str¶
Returns the translated, user-visible name for the format with matching
id
.- Parameters
id (str) –
- Return type
str