QDoubleValidator Class Reference

[ QtGui module]

The QDoubleValidator class provides range checking of floating-point numbers. 更多...

继承 QValidator .

类型

方法


详细描述

The QDoubleValidator class provides range checking of floating-point numbers.

QDoubleValidator provides an upper bound, a lower bound, and a limit on the number of digits after the decimal point. It does not provide a fixup () 函数。

You can set the acceptable range in one call with setRange (), or with setBottom () 和 setTop (). Set the number of decimal places with setDecimals ()。 validate () function returns the validation state.

QDoubleValidator uses its locale () to interpret the number. For example, in the German locale, "1,234" will be accepted as the fractional number 1.234. In Arabic locales, QDoubleValidator will accept Arabic digits.

In addition, QDoubleValidator is always guaranteed to accept a number formatted according to the "C" locale. QDoubleValidator will not accept numbers with thousand-separators.


类型文档编制

QDoubleValidator.Notation

This enum defines the allowed notations for entering a double.

常量 描述
QDoubleValidator.StandardNotation 0 The string is written as a standard number (i.e. 0.015).
QDoubleValidator.ScientificNotation 1 The string is written in scientific form. It may have an exponent part(i.e. 1.5E-2).

该枚举在 Qt 4.3 引入或被修改。


方法文档编制

QDoubleValidator.__init__ ( self , QObject   parent  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a validator object with a parent object that accepts any double.

QDoubleValidator.__init__ ( self , float  bottom , float  top , int  decimals , QObject   parent  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a validator object with a parent object. This validator will accept doubles from bottom to top inclusive, with up to decimals digits after the decimal point.

float QDoubleValidator.bottom ( self )

int QDoubleValidator.decimals ( self )

Notation QDoubleValidator.notation ( self )

QDoubleValidator.setBottom ( self , float)

QDoubleValidator.setDecimals ( self , int)

QDoubleValidator.setNotation ( self , Notation )

QDoubleValidator.setRange ( self , float  minimum , float  maximum , int  decimals  = 0)

Sets the validator to accept doubles from minimum to maximum inclusive, with at most decimals digits after the decimal point.

QDoubleValidator.setTop ( self , float)

float QDoubleValidator.top ( self )

( QValidator.State , QString, int) QDoubleValidator.validate ( self , QString, int)

重实现自 QValidator.validate ().

返回 Acceptable if the string input contains a double that is within the valid range and is in the correct format.

返回 中间体 if input contains a double that is outside the range or is in the wrong format; e.g. with too many digits after the decimal point or is empty.

返回 Invalid input is not a double.

Note: If the valid range consists of just positive doubles (e.g. 0.0 to 100.0) and input is a negative double then Invalid 被返回。若 notation () 被设为 StandardNotation , and the input contains more digits before the decimal point than a double in the valid range may have, Invalid 被返回。若 notation () 是 ScientificNotation ,和 the input is not in the valid range, 中间体 is returned. The value may yet become valid by changing the exponent.

默认情况下, pos parameter is not used by this validator.

( QValidator.State , int) QDoubleValidator.validate ( self , QString, int)