<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- qvalidator.cpp --> <head> <title>Qt 4.6: QDoubleValidator Class Reference</title> <link href="classic.css" rel="stylesheet" type="text/css" /> </head> <body> <a name="//apple_ref/cpp/cl//QDoubleValidator"></a> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td> <td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="functions.html"><font color="#004faf">All Functions</font></a> · <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title">QDoubleValidator Class Reference<br /><span class="small-subtitle">[<a href="qtgui.html">QtGui</a> module]</span> </h1> <p>The QDoubleValidator class provides range checking of floating-point numbers. <a href="#details">More...</a></p> <pre> #include <QDoubleValidator></pre><p>Inherits <a href="qvalidator.html">QValidator</a>.</p> <ul> <li><a href="qdoublevalidator-members.html">List of all members, including inherited members</a></li> <li><a href="qdoublevalidator-qt3.html">Qt 3 support members</a></li> </ul> <hr /> <a name="public-types"></a> <h2>Public Types</h2> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top">enum </td><td class="memItemRight" valign="bottom"><b><a href="qdoublevalidator.html#Notation-enum">Notation</a></b> { StandardNotation, ScientificNotation }</td></tr> </table> <hr /> <a name="properties"></a> <h2>Properties</h2> <ul> <li><div class="fn"><b><a href="qdoublevalidator.html#bottom-prop">bottom</a></b> : double</div></li> <li><div class="fn"><b><a href="qdoublevalidator.html#decimals-prop">decimals</a></b> : int</div></li> <li><div class="fn"><b><a href="qdoublevalidator.html#notation-prop">notation</a></b> : Notation</div></li> <li><div class="fn"><b><a href="qdoublevalidator.html#top-prop">top</a></b> : double</div></li> </ul> <ul> <li><div bar="2" class="fn"></div>1 property inherited from <a href="qobject.html#properties">QObject</a></li> </ul> <hr /> <a name="public-functions"></a> <h2>Public Functions</h2> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qdoublevalidator.html#QDoubleValidator">QDoubleValidator</a></b> ( QObject * <i>parent</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qdoublevalidator.html#QDoubleValidator-2">QDoubleValidator</a></b> ( double <i>bottom</i>, double <i>top</i>, int <i>decimals</i>, QObject * <i>parent</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qdoublevalidator.html#dtor.QDoubleValidator">~QDoubleValidator</a></b> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top">double </td><td class="memItemRight" valign="bottom"><b><a href="qdoublevalidator.html#bottom-prop">bottom</a></b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qdoublevalidator.html#decimals-prop">decimals</a></b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">Notation </td><td class="memItemRight" valign="bottom"><b><a href="qdoublevalidator.html#notation-prop">notation</a></b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qdoublevalidator.html#bottom-prop">setBottom</a></b> ( double )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qdoublevalidator.html#decimals-prop">setDecimals</a></b> ( int )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qdoublevalidator.html#notation-prop">setNotation</a></b> ( Notation )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="qdoublevalidator.html#setRange">setRange</a></b> ( double <i>minimum</i>, double <i>maximum</i>, int <i>decimals</i> = 0 )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qdoublevalidator.html#top-prop">setTop</a></b> ( double )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">double </td><td class="memItemRight" valign="bottom"><b><a href="qdoublevalidator.html#top-prop">top</a></b> () const</td></tr> </table> <hr /> <a name="reimplemented-public-functions"></a> <h2>Reimplemented Public Functions</h2> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top">virtual QValidator::State </td><td class="memItemRight" valign="bottom"><b><a href="qdoublevalidator.html#validate">validate</a></b> ( QString & <i>input</i>, int & <i>pos</i> ) const</td></tr> </table> <ul> <li><div bar="2" class="fn"></div>4 public functions inherited from <a href="qvalidator.html#public-functions">QValidator</a></li> <li><div bar="2" class="fn"></div>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li> </ul> <h3>Additional Inherited Members</h3> <ul> <li><div class="fn"></div>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li> <li><div class="fn"></div>1 signal inherited from <a href="qobject.html#signals">QObject</a></li> <li><div class="fn"></div>5 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li> <li><div class="fn"></div>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li> </ul> <a name="details"></a> <hr /> <h2>Detailed Description</h2> <p>The QDoubleValidator class provides range checking of floating-point numbers.</p> <p>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 <a href="qvalidator.html#fixup">fixup</a>() function.</p> <p>You can set the acceptable range in one call with <a href="qdoublevalidator.html#setRange">setRange</a>(), or with <a href="qdoublevalidator.html#bottom-prop">setBottom</a>() and <a href="qdoublevalidator.html#top-prop">setTop</a>(). Set the number of decimal places with <a href="qdoublevalidator.html#decimals-prop">setDecimals</a>(). The <a href="qdoublevalidator.html#validate">validate</a>() function returns the validation state.</p> <p>QDoubleValidator uses its <a href="qvalidator.html#locale">locale</a>() 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.</p> <p>In addition, QDoubleValidator is always guaranteed to accept a number formatted according to the "C" locale. QDoubleValidator will not accept numbers with thousand-seperators.</p> <p>See also <a href="qintvalidator.html">QIntValidator</a>, <a href="qregexpvalidator.html">QRegExpValidator</a>, and <a href="widgets-lineedits.html">Line Edits Example</a>.</p> <hr /> <h2>Member Type Documentation</h2> <a name="//apple_ref/cpp/tag/QDoubleValidator/Notation"></a> <a name="//apple_ref/cpp/econst/QDoubleValidator/StandardNotation"></a> <a name="//apple_ref/cpp/econst/QDoubleValidator/ScientificNotation"></a> <h3 class="fn"><a name="Notation-enum"></a>enum QDoubleValidator::Notation</h3> <p>This enum defines the allowed notations for entering a double.</p> <p><table class="valuelist" border="1" cellpadding="2" cellspacing="1" width="100%"> <tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr> <tr><td valign="top"><tt>QDoubleValidator::StandardNotation</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">The string is written as a standard number (i.e. 0.015).</td></tr> <tr><td valign="top"><tt>QDoubleValidator::ScientificNotation</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">The string is written in scientific form. It may have an exponent part(i.e. 1.5E-2).</td></tr> </table></p> <p>This enum was introduced in Qt 4.3.</p> <hr /> <h2>Property Documentation</h2> <a name="//apple_ref/cpp/instm/QDoubleValidator/bottom"></a> <a name="//apple_ref/cpp/instm/QDoubleValidator/setBottom"></a> <h3 class="fn"><a name="bottom-prop"></a>bottom : double</h3> <p>This property holds the validator's minimum acceptable value.</p> <p>By default, this property contains a value of -infinity.</p> <p><b>Access functions:</b></p> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top">double </td><td class="memItemRight" valign="bottom"><b>bottom</b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b>setBottom</b> ( double )</td></tr> </table> <p>See also <a href="qdoublevalidator.html#setRange">setRange</a>().</p> <a name="//apple_ref/cpp/instm/QDoubleValidator/decimals"></a> <a name="//apple_ref/cpp/instm/QDoubleValidator/setDecimals"></a> <h3 class="fn"><a name="decimals-prop"></a>decimals : int</h3> <p>This property holds the validator's maximum number of digits after the decimal point.</p> <p>By default, this property contains a value of 1000.</p> <p><b>Access functions:</b></p> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b>decimals</b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b>setDecimals</b> ( int )</td></tr> </table> <p>See also <a href="qdoublevalidator.html#setRange">setRange</a>().</p> <a name="//apple_ref/cpp/instm/QDoubleValidator/notation"></a> <a name="//apple_ref/cpp/instm/QDoubleValidator/setNotation"></a> <h3 class="fn"><a name="notation-prop"></a>notation : <a href="qdoublevalidator.html#Notation-enum">Notation</a></h3> <p>This property holds the notation of how a string can describe a number.</p> <p>By default, this property is set to <a href="qdoublevalidator.html#Notation-enum">ScientificNotation</a>.</p> <p>This property was introduced in Qt 4.3.</p> <p><b>Access functions:</b></p> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top">Notation </td><td class="memItemRight" valign="bottom"><b>notation</b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b>setNotation</b> ( Notation )</td></tr> </table> <p>See also <a href="qdoublevalidator.html#Notation-enum">Notation</a>.</p> <a name="//apple_ref/cpp/instm/QDoubleValidator/top"></a> <a name="//apple_ref/cpp/instm/QDoubleValidator/setTop"></a> <h3 class="fn"><a name="top-prop"></a>top : double</h3> <p>This property holds the validator's maximum acceptable value.</p> <p>By default, this property contains a value of infinity.</p> <p><b>Access functions:</b></p> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top">double </td><td class="memItemRight" valign="bottom"><b>top</b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b>setTop</b> ( double )</td></tr> </table> <p>See also <a href="qdoublevalidator.html#setRange">setRange</a>().</p> <hr /> <h2>Member Function Documentation</h2> <a name="//apple_ref/cpp/instm/QDoubleValidator/QDoubleValidator"></a> <h3 class="fn"><a name="QDoubleValidator"></a>QDoubleValidator::QDoubleValidator ( <a href="qobject.html">QObject</a> * <i>parent</i> )</h3> <p>Constructs a validator object with a <i>parent</i> object that accepts any double.</p> <h3 class="fn"><a name="QDoubleValidator-2"></a>QDoubleValidator::QDoubleValidator ( double <i>bottom</i>, double <i>top</i>, int <i>decimals</i>, <a href="qobject.html">QObject</a> * <i>parent</i> )</h3> <p>Constructs a validator object with a <i>parent</i> object. This validator will accept doubles from <i>bottom</i> to <i>top</i> inclusive, with up to <i>decimals</i> digits after the decimal point.</p> <a name="//apple_ref/cpp/instm/QDoubleValidator/~QDoubleValidator"></a> <h3 class="fn"><a name="dtor.QDoubleValidator"></a>QDoubleValidator::~QDoubleValidator ()</h3> <p>Destroys the validator.</p> <a name="//apple_ref/cpp/instm/QDoubleValidator/setRange"></a> <h3 class="fn"><a name="setRange"></a>void QDoubleValidator::setRange ( double <i>minimum</i>, double <i>maximum</i>, int <i>decimals</i> = 0 ) <tt> [virtual]</tt></h3> <p>Sets the validator to accept doubles from <i>minimum</i> to <i>maximum</i> inclusive, with at most <i>decimals</i> digits after the decimal point.</p> <a name="//apple_ref/cpp/instm/QDoubleValidator/validate"></a> <h3 class="fn"><a name="validate"></a><a href="qvalidator.html#State-enum">QValidator::State</a> QDoubleValidator::validate ( <a href="qstring.html">QString</a> & <i>input</i>, int & <i>pos</i> ) const <tt> [virtual]</tt></h3> <p>Reimplemented from <a href="qvalidator.html#validate">QValidator::validate</a>().</p> <p>Returns <a href="qvalidator.html#State-enum">Acceptable</a> if the string <i>input</i> contains a double that is within the valid range and is in the correct format.</p> <p>Returns <a href="qvalidator.html#State-enum">Intermediate</a> if <i>input</i> 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.</p> <p>Returns <a href="qvalidator.html#State-enum">Invalid</a> if the <i>input</i> is not a double.</p> <p>Note: If the valid range consists of just positive doubles (e.g. 0.0 to 100.0) and <i>input</i> is a negative double then <a href="qvalidator.html#State-enum">Invalid</a> is returned. If <a href="qdoublevalidator.html#notation-prop">notation</a>() is set to <a href="qdoublevalidator.html#Notation-enum">StandardNotation</a>, and the input contains more digits before the decimal point than a double in the valid range may have, <a href="qvalidator.html#State-enum">Invalid</a> is returned. If <a href="qdoublevalidator.html#notation-prop">notation</a>() is <a href="qdoublevalidator.html#Notation-enum">ScientificNotation</a>, and the input is not in the valid range, <a href="qvalidator.html#State-enum">Intermediate</a> is returned. The value may yet become valid by changing the exponent.</p> <p>By default, the <i>pos</i> parameter is not used by this validator.</p> <p /><address><hr /><div align="center"> <table width="100%" cellspacing="0" border="0"><tr class="address"> <td width="40%" align="left">Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)</td> <td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td> <td width="40%" align="right"><div align="right">Qt 4.6.3</div></td> </tr></table></div></address></body> </html>