Class: QgsDoubleValidator

A custom validator which allows entry of doubles in a locale-tolerant way.

QgsDoubleValidator is a QLineEdit Validator that combines QDoubleValidator and QRegularExpressionValidator to allow users to enter doubles with both local and C interpretation as a fallback.

Added in version 3.14.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsDoubleValidator

Base classes

QRegularExpressionValidator

QValidator

QObject

class qgis.gui.QgsDoubleValidator[source]

Bases: QRegularExpressionValidator

__init__(parent: QObject | None)

Constructor for QgsDoubleValidator.

Parameters:

parent (Optional[QObject])

__init__(expression: QRegularExpression, bottom: float, top: float, parent: QObject | None)

Constructor for QgsDoubleValidator.

Parameters:
  • bottom (float) – the minimal range limit accepted by the validator

  • top (float) – the maximal range limit accepted by the validator

  • parent (Optional[QObject]) – parent object

  • expression (QRegularExpression) – custom regular expression

__init__(bottom: float, top: float, parent: QObject | None)

Constructor for QgsDoubleValidator.

Parameters:
  • bottom (float) – the minimal range limit accepted by the validator

  • top (float) – the maximal range limit accepted by the validator

  • parent (Optional[QObject]) – parent object

__init__(bottom: float, top: float, decimal: int, parent: QObject | None)

Constructor for QgsDoubleValidator.

Parameters:
  • bottom (float) – the minimal range limit accepted by the validator

  • top (float) – the maximal range limit accepted by the validator

  • decimal (int) – the number of decimals accepted by the validator

  • parent (Optional[QObject]) – parent object

__init__(decimal: int, parent: QObject | None)

Constructor for QgsDoubleValidator.

Parameters:
  • decimal (int) – the number of decimals accepted by the validator

  • parent (Optional[QObject]) – parent object

Added in version 3.16.

bottom(self) float[source]

Returns top range limit

See also

setBottom()

Return type:

float

setBottom(self, bottom: float)[source]

Set top range limit

See also

setTop()

See also

setRange()

Parameters:

bottom (float)

setMaxDecimals(self, maxDecimals: int)[source]

Sets the number of decimals accepted by the validator to maxDecimals.

Warning

setting decimals overrides any custom regular expression that was previously set

Added in version 3.22.

Parameters:

maxDecimals (int)

virtual setRange(self, bottom: float, top: float)[source]

Set bottom and top range limits

See also

setBottom()

See also

setTop()

Parameters:
  • bottom (float)

  • top (float)

setTop(self, top: float)[source]

Set top range limit

See also

setBottom()

See also

setRange()

Parameters:

top (float)

static toDouble(input: str | None) float[source]

Converts input string to double value. It uses locale interpretation first and C locale interpretation as fallback

Parameters:

input (Optional[str])

Return type:

float

top(self) float[source]

Returns top range limit

See also

setTop()

Return type:

float

validate(self, input: str | None) QValidator.State[source]

Evaluates input string validity according to QRegularExpression and ability to be converted in double value.

Parameters:

input (Optional[str])

Return type:

QValidator.State