CopperSpice API  1.9.2
QDoubleValidator Class Reference

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

Inheritance diagram for QDoubleValidator:
QValidator QObject

Public Types

enum  Notation
 
- Public Types inherited from QValidator
enum  State
 

Public Signals

void bottomChanged (double newValue)
 
void decimalsChanged (int decimals)
 
void notationChanged (QDoubleValidator::Notation notation)
 
void topChanged (double newValue)
 
- Public Signals inherited from QValidator
void changed ()
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Methods

 QDoubleValidator (double minimum, double maximum, int decimals, QObject *parent=nullptr)
 
 QDoubleValidator (QObject *parent=nullptr)
 
 ~QDoubleValidator ()
 
double bottom () const
 
int decimals () const
 
Notation notation () const
 
void setBottom (double newValue)
 
void setDecimals (int decimals)
 
void setNotation (Notation notation)
 
virtual void setRange (double minimum, double maximum, int decimals=0)
 
void setTop (double newValue)
 
double top () const
 
QValidator::State validate (QString &input, int &pos) const override
 
- Public Methods inherited from QValidator
 QValidator (QObject *parent=nullptr)
 
 ~QValidator ()
 
virtual void fixup (QString &input) const
 
QLocale locale () const
 
void setLocale (const QLocale &locale)
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 

Properties

 bottom
 
 decimals
 
 notation
 
 top
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Detailed Description

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() method.

You can set the acceptable range in one call with setRange(), or with setBottom() and setTop(). Set the number of decimal places with setDecimals(). The 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.

See also
QIntValidator, QRegularExpressionValidator

Member Enumeration Documentation

This enum defines the allowed notations for entering a double.

ConstantValueDescription
QDoubleValidator::StandardNotation0 The string is written as a standard number (i.e. 0.015).
QDoubleValidator::ScientificNotation1 The string is written in scientific form. It may have an exponent part(i.e. 1.5E-2).

Constructor & Destructor Documentation

QDoubleValidator::QDoubleValidator ( QObject parent = nullptr)
explicit

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

QDoubleValidator::QDoubleValidator ( double  minimum,
double  maximum,
int  decimals,
QObject parent = nullptr 
)

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.

QDoubleValidator::~QDoubleValidator ( )

Destroys the validator.

Method Documentation

double QDoubleValidator::bottom ( ) const
inline

Returns the value of the property.

void QDoubleValidator::bottomChanged ( double  newValue)
signal

This signal is emitted when the value of the property changes. The specified newValue represents the updated value.

int QDoubleValidator::decimals ( ) const
inline

Returns the value of the property.

void QDoubleValidator::decimalsChanged ( int  decimals)
signal

This signal is emitted when the value of the property changes. The specified decimals represents the updated value.

Notation QDoubleValidator::notation ( ) const

Returns the value of the property.

void QDoubleValidator::notationChanged ( QDoubleValidator::Notation  notation)
signal

Returns an icon for the file described by notation.

void QDoubleValidator::setBottom ( double  newValue)

Sets the value of the property to newValue.

void QDoubleValidator::setDecimals ( int  decimals)

Sets the value of the property to decimals.

void QDoubleValidator::setNotation ( Notation  notation)

Sets the value of the property to newValue.

void QDoubleValidator::setRange ( double  minimum,
double  maximum,
int  decimals = 0 
)
virtual

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

void QDoubleValidator::setTop ( double  newValue)

Sets the value of the property to newValue.

double QDoubleValidator::top ( ) const
inline

Returns the value of the property.

void QDoubleValidator::topChanged ( double  newValue)
signal

This signal is emitted when the value of the property changes. The specified newValue represents the updated value.

QValidator::State QDoubleValidator::validate ( QString input,
int &  pos 
) const
overridevirtual

The implementation in QDoubleValidator ignores the pos parameter.

  • Returns Acceptable if the string input contains a double that is within the valid range and is in the correct format.
  • Returns Intermediate if input contains a double that is outside the range or is in the wrong format. For example with too many digits after the decimal point or is empty.
  • Returns Invalid if the input is not a double. If the valid range consists of positive values and input is a negative number then Invalid is returned.

If notation() is set to StandardNotation and the input contains more digits before the decimal point than any number in the valid range Invalid is returned.

If notation() is ScientificNotation and the input is not in the valid range, Intermediate is returned.

Implements QValidator::validate()

Property Documentation

QDoubleValidator::bottom

This property holds the validator's minimum acceptable value. By default, this property contains a value of -infinity.

See also
setRange()
PropertiesClass Methods
read bottom
write setBottom
notify bottomChanged
QDoubleValidator::decimals

This property holds the validator's maximum number of digits after the decimal point. By default, this property contains a value of 1000.

See also
setRange()
PropertiesClass Methods
read decimals
write setDecimals
notify decimalsChanged
QDoubleValidator::notation

This property holds the notation of how a string can describe a number. By default, this property is set to ScientificNotation.

See also
Notation
PropertiesClass Methods
read notation
write setNotation
notify notationChanged
QDoubleValidator::top

This property holds the validator's maximum acceptable value.By default, this property contains a value of infinity.

See also
setRange()
PropertiesClass Methods
read top
write setTop
notify topChanged