Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Tous les espaces de nom  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QDoubleValidator Class Reference
[QtGui module]

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

 #include <QDoubleValidator>

Inherits QValidator.

Public Types

  • enum Notation { StandardNotation, ScientificNotation }

Properties

  • 1 property inherited from QObject

Public Functions

  • 4 public functions inherited from QValidator
  • 29 public functions inherited from QObject

Additional Inherited Members

  • 1 public slot inherited from QObject
  • 1 signal inherited from QObject
  • 5 static public members inherited from QObject
  • 7 protected functions inherited from QObject

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

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-seperators.

See also QIntValidator, QRegExpValidator, and Line Edits Example.


Member Type Documentation

enum QDoubleValidator::Notation

This enum defines the allowed notations for entering a double.

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

This enum was introduced in Qt 4.3.


Property Documentation

bottom : double

This property holds the validator's minimum acceptable value.

By default, this property contains a value of -infinity.

Access functions:

  • double bottom () const
  • void setBottom ( double )

See also setRange().

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.

Access functions:

  • int decimals () const
  • void setDecimals ( int )

See also setRange().

notation : Notation

This property holds the notation of how a string can describe a number.

By default, this property is set to ScientificNotation.

This property was introduced in Qt 4.3.

Access functions:

  • Notation notation () const
  • void setNotation ( Notation )

See also Notation.

top : double

This property holds the validator's maximum acceptable value.

By default, this property contains a value of infinity.

Access functions:

  • double top () const
  • void setTop ( double )

See also setRange().


Member Function Documentation

QDoubleValidator::QDoubleValidator ( QObject * parent )

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

QDoubleValidator::QDoubleValidator ( double bottom, double top, int decimals, QObject * parent )

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.

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.

QValidator::State QDoubleValidator::validate ( QString & input, int & pos ) const   [virtual]

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; e.g. with too many digits after the decimal point or is empty.

Returns Invalid if the 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 is returned. If notation() is set to StandardNotation, and the input contains more digits before the decimal point than a double in the valid range may have, Invalid is returned. If notation() is ScientificNotation, and the input is not in the valid range, Intermediate is returned. The value may yet become valid by changing the exponent.

By default, the pos parameter is not used by this validator.

Reimplemented from QValidator.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année

Le Qt Labs au hasard

Logo

QLocale : à propos du temps (et des dates, et des langues, et des...)

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.4
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web