Defines a validator for non-integer numbers. More...
| Import Statement: | import QtQuick |
| In C++: | QDoubleValidator |
The DoubleValidator type provides a validator for non-integer numbers.
Note: If the valid range consists of only positive doubles (for example, 0.0 to 100.0) and the input is a negative double, it is rejected. If notation
is set to DoubleValidator.StandardNotation and the input contains more digits before the decimal point than a double in the valid range may have, it is also rejected. If notation is DoubleValidator.ScientificNotation and the input is not in the valid range, it is accepted but invalid. The value may become valid
by changing the exponent.
The following example shows a TextInput object with a DoubleValidator to check that the user has input a double within the specified range, updating the text color to highlight invalid input:
import QtQuick TextInput { focus: true validator: DoubleValidator { bottom: 0.00 top: 100.00 decimals: 2 notation: DoubleValidator.StandardNotation } onAcceptableInputChanged: color = acceptableInput ? "black" : "red"; }
See also IntValidator, RegularExpressionValidator, and Validating Input Text.
|
bottom : real |
This property holds the validator's minimum acceptable value. By default, this property contains a value of -infinity.
|
decimals : int |
This property holds the validator's maximum number of digits after the decimal point. By default, this property contains a value of 1000.
|
locale : string |
This property holds the name of the locale used to interpret the number.
See also Qt.locale().
|
notation : enumeration |
This property holds the notation of how a string can describe a number.
The possible values for this property are:
| Constant | Description |
|---|---|
DoubleValidator.StandardNotation |
only decimal numbers with optional sign (e.g. -0.015) |
DoubleValidator.ScientificNotation |
(default) the written number may have an exponent part (e.g. 1.5E-2) |
|
top : real |
This property holds the validator's maximum acceptable value. By default, this property contains a value of infinity.
As part of the free Business evaluation, we offer a free welcome call for companies, to talk about your requirements, and how the Felgo SDK & Services can help you. Just sign up and schedule your call.
Sign up now to start your free Business evaluation: