Class: QgsBasicNumericFormat

A numeric formatter which returns a simple text representation of a value.

Added in version 3.12.

Class Hierarchy

Inheritance diagram of qgis.core.QgsBasicNumericFormat

Base classes

QgsNumericFormat

Abstract base class for numeric formatters, which allow for formatting a numeric value for display.

Subclasses

QgsBearingNumericFormat

A numeric formatter which returns a text representation of a direction/bearing.

QgsCurrencyNumericFormat

A numeric formatter which returns a text representation of a currency value.

QgsGeographicCoordinateNumericFormat

A numeric formatter which returns a text representation of a geographic coordinate (latitude or longitude).

QgsPercentageNumericFormat

A numeric formatter which returns a text representation of a percentage value.

QgsScientificNumericFormat

A numeric formatter which returns a scientific notation representation of a value.

class qgis.core.QgsBasicNumericFormat[source]

Bases: QgsNumericFormat

__init__()

Default constructor

__init__(a0: QgsBasicNumericFormat)
Parameters:

a0 (QgsBasicNumericFormat)

DecimalPlaces = 0
class RoundingType

Bases: int

SignificantFigures = 1
decimalSeparator(self) str[source]

Returns any override for the decimal separator character. If an invalid QChar is returned, then the QGIS locale separator is used instead.

Return type:

str

numberDecimalPlaces(self) int[source]

Returns the maximum number of decimal places to show.

Return type:

int

roundingType(self) QgsBasicNumericFormat.RoundingType[source]

Returns the rounding type, which controls the behavior of the numberDecimalPlaces() setting.

Return type:

QgsBasicNumericFormat.RoundingType

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

Sets the format’s configuration.

Parameters:
setDecimalSeparator(self, character: str)[source]

Sets an override character for the decimal separator character. If an invalid QChar is set, then the QGIS locale separator is used instead.

Parameters:

character (str)

virtual setNumberDecimalPlaces(self, places: int)[source]

Sets the maximum number of decimal places to show.

Parameters:

places (int)

setRoundingType(self, type: QgsBasicNumericFormat.RoundingType)[source]

Sets the rounding type, which controls the behavior of the numberDecimalPlaces() setting.

See also

roundingType()

Parameters:

type (QgsBasicNumericFormat.RoundingType)

setShowPlusSign(self, show: bool)[source]

Sets whether a leading plus sign will be shown for positive values.

See also

showPlusSign()

Parameters:

show (bool)

setShowThousandsSeparator(self, show: bool)[source]

Sets whether the thousands grouping separator will be shown.

Parameters:

show (bool)

setShowTrailingZeros(self, show: bool)[source]

Sets whether trailing zeros will be shown (up to the specified numberDecimalPlaces()).

Parameters:

show (bool)

setThousandsSeparator(self, character: str)[source]

Sets an override character for the thousands separator character. If an invalid QChar is set, then the QGIS locale separator is used instead.

Parameters:

character (str)

showPlusSign(self) bool[source]

Returns True if a leading plus sign will be shown for positive values.

Return type:

bool

showThousandsSeparator(self) bool[source]

Returns True if the thousands grouping separator will be shown.

Return type:

bool

showTrailingZeros(self) bool[source]

Returns True if trailing zeros will be shown (up to the specified numberDecimalPlaces()).

Return type:

bool

thousandsSeparator(self) str[source]

Returns any override for the thousands separator character. If an invalid QChar is returned, then the QGIS locale separator is used instead.

Return type:

str