<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qvalidator.cpp --> <title>Qt 4.8: QDoubleValidator Class Reference</title> <link rel="stylesheet" type="text/css" href="style/style.css" /> <script src="scripts/jquery.js" type="text/javascript"></script> <script src="scripts/functions.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="style/superfish.css" /> <link rel="stylesheet" type="text/css" href="style/narrow.css" /> <!--[if IE]> <meta name="MSSmartTagsPreventParsing" content="true"> <meta http-equiv="imagetoolbar" content="no"> <![endif]--> <!--[if lt IE 7]> <link rel="stylesheet" type="text/css" href="style/style_ie6.css"> <![endif]--> <!--[if IE 7]> <link rel="stylesheet" type="text/css" href="style/style_ie7.css"> <![endif]--> <!--[if IE 8]> <link rel="stylesheet" type="text/css" href="style/style_ie8.css"> <![endif]--> <script src="scripts/superfish.js" type="text/javascript"></script> <script src="scripts/narrow.js" type="text/javascript"></script> </head> <body class="" onload="CheckEmptyAndLoadList();"> <div class="header" id="qtdocheader"> <div class="content"> <div id="nav-logo"> <a href="index.html">Home</a></div> <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a> <div id="narrowsearch"></div> <div id="nav-topright"> <ul> <li class="nav-topright-home"><a href="http://qt.digia.com/">Qt HOME</a></li> <li class="nav-topright-dev"><a href="http://qt-project.org/">DEV</a></li> <li class="nav-topright-doc nav-topright-doc-active"><a href="http://qt-project.org/doc/"> DOC</a></li> <li class="nav-topright-blog"><a href="http://blog.qt.digia.com/">BLOG</a></li> </ul> </div> <div id="shortCut"> <ul> <li class="shortCut-topleft-inactive"><span><a href="index.html">Qt 4.8</a></span></li> <li class="shortCut-topleft-active"><a href="http://qt-project.org/doc/">ALL VERSIONS </a></li> </ul> </div> <ul class="sf-menu" id="narrowmenu"> <li><a href="#">API Lookup</a> <ul> <li><a href="classes.html">Class index</a></li> <li><a href="functions.html">Function index</a></li> <li><a href="modules.html">Modules</a></li> <li><a href="namespaces.html">Namespaces</a></li> <li><a href="qtglobal.html">Global Declarations</a></li> <li><a href="qdeclarativeelements.html">QML elements</a></li> </ul> </li> <li><a href="#">Qt Topics</a> <ul> <li><a href="qt-basic-concepts.html">Programming with Qt</a></li> <li><a href="qtquick.html">Device UIs & Qt Quick</a></li> <li><a href="qt-gui-concepts.html">UI Design with Qt</a></li> <li><a href="supported-platforms.html">Supported Platforms</a></li> <li><a href="technology-apis.html">Qt and Key Technologies</a></li> <li><a href="best-practices.html">How-To's and Best Practices</a></li> </ul> </li> <li><a href="#">Examples</a> <ul> <li><a href="all-examples.html">Examples</a></li> <li><a href="tutorials.html">Tutorials</a></li> <li><a href="demos.html">Demos</a></li> <li><a href="qdeclarativeexamples.html">QML Examples</a></li> </ul> </li> </ul> </div> </div> <div class="wrapper"> <div class="hd"> <span></span> </div> <div class="bd group"> <div class="sidebar"> <div class="searchlabel"> Search index:</div> <div class="search" id="sidebarsearch"> <form id="qtdocsearch" action="" onsubmit="return false;"> <fieldset> <input type="text" name="searchstring" id="pageType" value="" /> <div id="resultdialog"> <a href="#" id="resultclose">Close</a> <p id="resultlinks" class="all"><a href="#" id="showallresults">All</a> | <a href="#" id="showapiresults">API</a> | <a href="#" id="showarticleresults">Articles</a> | <a href="#" id="showexampleresults">Examples</a></p> <p id="searchcount" class="all"><span id="resultcount"></span><span id="apicount"></span><span id="articlecount"></span><span id="examplecount"></span> results:</p> <ul id="resultlist" class="all"> </ul> </div> </fieldset> </form> </div> <div class="box first bottombar" id="lookup"> <h2 title="API Lookup"><span></span> API Lookup</h2> <div id="list001" class="list"> <ul id="ul001" > <li class="defaultLink"><a href="classes.html">Class index</a></li> <li class="defaultLink"><a href="functions.html">Function index</a></li> <li class="defaultLink"><a href="modules.html">Modules</a></li> <li class="defaultLink"><a href="namespaces.html">Namespaces</a></li> <li class="defaultLink"><a href="qtglobal.html">Global Declarations</a></li> <li class="defaultLink"><a href="qdeclarativeelements.html">QML elements</a></li> </ul> </div> </div> <div class="box bottombar" id="topics"> <h2 title="Qt Topics"><span></span> Qt Topics</h2> <div id="list002" class="list"> <ul id="ul002" > <li class="defaultLink"><a href="qt-basic-concepts.html">Programming with Qt</a></li> <li class="defaultLink"><a href="qtquick.html">Device UIs & Qt Quick</a></li> <li class="defaultLink"><a href="qt-gui-concepts.html">UI Design with Qt</a></li> <li class="defaultLink"><a href="supported-platforms.html">Supported Platforms</a></li> <li class="defaultLink"><a href="technology-apis.html">Qt and Key Technologies</a></li> <li class="defaultLink"><a href="best-practices.html">How-To's and Best Practices</a></li> </ul> </div> </div> <div class="box" id="examples"> <h2 title="Examples"><span></span> Examples</h2> <div id="list003" class="list"> <ul id="ul003"> <li class="defaultLink"><a href="all-examples.html">Examples</a></li> <li class="defaultLink"><a href="tutorials.html">Tutorials</a></li> <li class="defaultLink"><a href="demos.html">Demos</a></li> <li class="defaultLink"><a href="qdeclarativeexamples.html">QML Examples</a></li> </ul> </div> </div> </div> <div class="wrap"> <div class="toolbar"> <div class="breadcrumb toolblock"> <ul> <li class="first"><a href="index.html">Home</a></li> <!-- Breadcrumbs go here --> <li><a href="modules.html">Modules</a></li> <li><a href="qtgui.html">QtGui</a></li> <li>QDoubleValidator</li> </ul> </div> <div class="toolbuttons toolblock"> <ul> <li id="smallA" class="t_button">A</li> <li id="medA" class="t_button active">A</li> <li id="bigA" class="t_button">A</li> <li id="print" class="t_button"><a href="javascript:this.print();"> <span>Print</span></a></li> </ul> </div> </div> <div class="content mainContent"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#public-types">Public Types</a></li> <li class="level1"><a href="#properties">Properties</a></li> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <h1 class="title">QDoubleValidator Class Reference</h1> <!-- $$$QDoubleValidator-brief --> <p>The QDoubleValidator class provides range checking of floating-point numbers. <a href="#details">More...</a></p> <!-- @@@QDoubleValidator --> <pre class="cpp"> <span class="preprocessor">#include <QDoubleValidator></span></pre><p><b>Inherits: </b><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> <a name="public-types"></a> <h2>Public Types</h2> <table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#Notation-enum">Notation</a></b> { StandardNotation, ScientificNotation }</td></tr> </table> <a name="properties"></a> <h2>Properties</h2> <ul> <li class="fn"><b><a href="qdoublevalidator.html#bottom-prop">bottom</a></b> : double</li> <li class="fn"><b><a href="qdoublevalidator.html#decimals-prop">decimals</a></b> : int</li> <li class="fn"><b><a href="qdoublevalidator.html#notation-prop">notation</a></b> : Notation</li> <li class="fn"><b><a href="qdoublevalidator.html#top-prop">top</a></b> : double</li> </ul> <ul> <li class="fn">1 property inherited from <a href="qobject.html#properties">QObject</a></li> </ul> <a name="public-functions"></a> <h2>Public Functions</h2> <table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#QDoubleValidator">QDoubleValidator</a></b> ( QObject * <i>parent</i> = 0 )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><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> = 0 )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#dtor.QDoubleValidator">~QDoubleValidator</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> double </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#bottom-prop">bottom</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#decimals-prop">decimals</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> Notation </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#notation-prop">notation</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#bottom-prop">setBottom</a></b> ( double )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#decimals-prop">setDecimals</a></b> ( int )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#notation-prop">setNotation</a></b> ( Notation )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><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 rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#top-prop">setTop</a></b> ( double )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> double </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#top-prop">top</a></b> () const</td></tr> </table> <a name="reimplemented-public-functions"></a> <h2>Reimplemented Public Functions</h2> <table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> virtual QValidator::State </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#validate">validate</a></b> ( QString & <i>input</i>, int & <i>pos</i> ) const</td></tr> </table> <ul> <li class="fn">4 public functions inherited from <a href="qvalidator.html#public-functions">QValidator</a></li> <li class="fn">29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li> </ul> <h3>Additional Inherited Members</h3> <ul> <li class="fn">1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li> <li class="fn">1 signal inherited from <a href="qobject.html#signals">QObject</a></li> <li class="fn">7 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li> <li class="fn">8 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li> </ul> <a name="details"></a> <!-- $$$QDoubleValidator-description --> <div class="descr"> <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-separators.</p> </div> <p><b>See also </b><a href="qintvalidator.html">QIntValidator</a>, <a href="qregexpvalidator.html">QRegExpValidator</a>, and <a href="widgets-lineedits.html">Line Edits Example</a>.</p> <!-- @@@QDoubleValidator --> <div class="types"> <h2>Member Type Documentation</h2> <!-- $$$Notation$$$StandardNotation$$$ScientificNotation --> <h3 class="fn"><a name="Notation-enum"></a>enum QDoubleValidator::<span class="name">Notation</span></h3> <p>This enum defines the allowed notations for entering a double.</p> <table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr> <tr><td class="topAlign"><tt>QDoubleValidator::StandardNotation</tt></td><td class="topAlign"><tt>0</tt></td><td class="topAlign">The string is written as a standard number (i.e. 0.015).</td></tr> <tr><td class="topAlign"><tt>QDoubleValidator::ScientificNotation</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign">The string is written in scientific form. It may have an exponent part(i.e. 1.5E-2).</td></tr> </table> <p>This enum was introduced or modified in Qt 4.3.</p> <!-- @@@Notation --> </div> <div class="prop"> <h2>Property Documentation</h2> <!-- $$$bottom-prop$$$bottom$$$setBottomdouble --> <h3 class="fn"><a name="bottom-prop"></a><span class="name">bottom</span> : <span class="type">double</span></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"> <tr><td class="memItemLeft topAlign rightAlign"> double </td><td class="memItemRight bottomAlign"><span class="name"><b>bottom</b></span> () const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setBottom</b></span> ( double )</td></tr> </table> <p><b>See also </b><a href="qdoublevalidator.html#setRange">setRange</a>().</p> <!-- @@@bottom --> <!-- $$$decimals-prop$$$decimals$$$setDecimalsint --> <h3 class="fn"><a name="decimals-prop"></a><span class="name">decimals</span> : <span class="type">int</span></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"> <tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>decimals</b></span> () const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setDecimals</b></span> ( int )</td></tr> </table> <p><b>See also </b><a href="qdoublevalidator.html#setRange">setRange</a>().</p> <!-- @@@decimals --> <!-- $$$notation-prop$$$notation$$$setNotationNotation --> <h3 class="fn"><a name="notation-prop"></a><span class="name">notation</span> : <span class="type"><a href="qdoublevalidator.html#Notation-enum">Notation</a></span></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"> <tr><td class="memItemLeft topAlign rightAlign"> Notation </td><td class="memItemRight bottomAlign"><span class="name"><b>notation</b></span> () const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setNotation</b></span> ( Notation )</td></tr> </table> <p><b>See also </b><a href="qdoublevalidator.html#Notation-enum">Notation</a>.</p> <!-- @@@notation --> <!-- $$$top-prop$$$top$$$setTopdouble --> <h3 class="fn"><a name="top-prop"></a><span class="name">top</span> : <span class="type">double</span></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"> <tr><td class="memItemLeft topAlign rightAlign"> double </td><td class="memItemRight bottomAlign"><span class="name"><b>top</b></span> () const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setTop</b></span> ( double )</td></tr> </table> <p><b>See also </b><a href="qdoublevalidator.html#setRange">setRange</a>().</p> <!-- @@@top --> </div> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QDoubleValidator[overload1]$$$QDoubleValidatorQObject* --> <h3 class="fn"><a name="QDoubleValidator"></a>QDoubleValidator::<span class="name">QDoubleValidator</span> ( <span class="type"><a href="qobject.html">QObject</a></span> * <i>parent</i> = 0 )</h3> <p>Constructs a validator object with a <i>parent</i> object that accepts any double.</p> <!-- @@@QDoubleValidator --> <!-- $$$QDoubleValidator$$$QDoubleValidatordoubledoubleintQObject* --> <h3 class="fn"><a name="QDoubleValidator-2"></a>QDoubleValidator::<span class="name">QDoubleValidator</span> ( <span class="type">double</span> <i>bottom</i>, <span class="type">double</span> <i>top</i>, <span class="type">int</span> <i>decimals</i>, <span class="type"><a href="qobject.html">QObject</a></span> * <i>parent</i> = 0 )</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> <!-- @@@QDoubleValidator --> <!-- $$$~QDoubleValidator[overload1]$$$~QDoubleValidator --> <h3 class="fn"><a name="dtor.QDoubleValidator"></a>QDoubleValidator::<span class="name">~QDoubleValidator</span> ()</h3> <p>Destroys the validator.</p> <!-- @@@~QDoubleValidator --> <!-- $$$setRange[overload1]$$$setRangedoubledoubleint --> <h3 class="fn"><a name="setRange"></a><span class="type">void</span> QDoubleValidator::<span class="name">setRange</span> ( <span class="type">double</span> <i>minimum</i>, <span class="type">double</span> <i>maximum</i>, <span class="type">int</span> <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> <!-- @@@setRange --> <!-- $$$validate[overload1]$$$validateQString&int& --> <h3 class="fn"><a name="validate"></a><span class="type"><a href="qvalidator.html#State-enum">QValidator::State</a></span> QDoubleValidator::<span class="name">validate</span> ( <span class="type"><a href="qstring.html">QString</a></span> & <i>input</i>, <span class="type">int</span> & <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> <!-- @@@validate --> </div> </div> </div> </div> <div class="ft"> <span></span> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2015 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.</p> <br /> <p> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.</p> <p> Documentation sources may be obtained from <a href="http://www.qt-project.org"> www.qt-project.org</a>.</p> <br /> <p> Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. <a title="Privacy Policy" href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p> </div> <script src="scripts/functions.js" type="text/javascript"></script> </body> </html>