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
Clones the format, returning a new object.
Returns the current configuration of the formatter.
Creates a new copy of the format, using the supplied
configuration
.Returns a formatted string representation of a numeric double value.
Returns a unique id for this numeric format.
Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists.
Returns a suggested sample value which nicely represents the current format configuration.
Returns the translated, user-visible name for this format.
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
- 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
configuration (Dict[str) –
context (QgsReadWriteContext) –
- Return type
- formatDouble(self, value: float, context: QgsNumericFormatContext) → str¶
Returns a formatted string representation of a numeric double value.
- Parameters
value (float) –
context (QgsNumericFormatContext) –
- 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
element (QDomElement) –
document (QDomDocument) –
context (QgsReadWriteContext) –