<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qvalidator.cpp --> <title>QDoubleValidator Class | Qt GUI 5.12.6</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td >Qt 5.12</td><td ><a href="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QDoubleValidator</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.12.6 Reference Documentation</a></td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"> <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="#reimplemented-public-functions">Reimplemented Public Functions</a></li> <li class="level1"><a href="#static-public-members">Static Public Members</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">QDoubleValidator Class</h1> <!-- $$$QDoubleValidator-brief --> <p>The <a href="qdoublevalidator.html">QDoubleValidator</a> class provides range checking of floating-point numbers. <a href="#details">More...</a></p> <!-- @@@QDoubleValidator --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QDoubleValidator></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qvalidator.html">QValidator</a></td></tr></table></div><ul> <li><a href="qdoublevalidator-members.html">List of all members, including inherited members</a></li> <li><a href="qdoublevalidator-obsolete.html">Obsolete members</a></li> </ul> <a name="public-types"></a> <h2 id="public-types">Public Types</h2> <div class="table"><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></div> <a name="properties"></a> <h2 id="properties">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="../qtcore/qobject.html#properties">QObject</a></li> </ul> <a name="public-functions"></a> <h2 id="public-functions">Public Functions</h2> <div class="table"><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> = nullptr)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#QDoubleValidator-1">QDoubleValidator</a></b>(double <i>bottom</i>, double <i>top</i>, int <i>decimals</i>, QObject *<i>parent</i> = nullptr)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual </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"> QDoubleValidator::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>(<i>double</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#decimals-prop">setDecimals</a></b>(<i>int</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#notation-prop">setNotation</a></b>(<i>QDoubleValidator::Notation</i>)</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>(<i>double</i>)</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></div> <a name="reimplemented-public-functions"></a> <h2 id="reimplemented-public-functions">Reimplemented Public Functions</h2> <div class="table"><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 override</td></tr> </table></div> <ul> <li class="fn">4 public functions inherited from <a href="qvalidator.html#public-functions">QValidator</a></li> <li class="fn">31 public functions inherited from <a href="../qtcore/qobject.html#public-functions">QObject</a></li> </ul> <a name="static-public-members"></a> <h2 id="static-public-members">Static Public Members</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> const QMetaObject </td><td class="memItemRight bottomAlign"><b><a href="qdoublevalidator.html#staticMetaObject-var">staticMetaObject</a></b></td></tr> </table></div> <ul> <li class="fn">9 static public members inherited from <a href="../qtcore/qobject.html#static-public-members">QObject</a></li> </ul> <h3>Additional Inherited Members</h3> <ul> <li class="fn">1 public slot inherited from <a href="../qtcore/qobject.html#public-slots">QObject</a></li> <li class="fn">1 signal inherited from <a href="qvalidator.html#signals">QValidator</a></li> <li class="fn">2 signals inherited from <a href="../qtcore/qobject.html#signals">QObject</a></li> <li class="fn">9 protected functions inherited from <a href="../qtcore/qobject.html#protected-functions">QObject</a></li> </ul> <a name="details"></a> <!-- $$$QDoubleValidator-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qdoublevalidator.html">QDoubleValidator</a> class provides range checking of floating-point numbers.</p> <p><a href="qdoublevalidator.html">QDoubleValidator</a> 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><a href="qdoublevalidator.html">QDoubleValidator</a> 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, <a href="qdoublevalidator.html">QDoubleValidator</a> will accept Arabic digits.</p> <p><b>Note: </b>The <a href="../qtcore/qlocale.html#NumberOption-enum">QLocale::NumberOptions</a> set on the <a href="qvalidator.html#locale">locale</a>() also affect the way the number is interpreted. For example, since <a href="../qtcore/qlocale.html#NumberOption-enum">QLocale::RejectGroupSeparator</a> is not set by default, the validator will accept group separators. It is thus recommended to use <a href="../qtcore/qlocale.html#toDouble-2">QLocale::toDouble</a>() to obtain the numeric value.</p></div> <p><b>See also </b><a href="qintvalidator.html">QIntValidator</a>, <a href="qregexpvalidator.html">QRegExpValidator</a>, <a href="../qtcore/qlocale.html#toDouble-2">QLocale::toDouble</a>(), and <a href="../qtwidgets/qtwidgets-widgets-lineedits-example.html">Line Edits Example</a>.</p> <!-- @@@QDoubleValidator --> <div class="types"> <h2>Member Type Documentation</h2> <!-- $$$Notation$$$StandardNotation$$$ScientificNotation --> <h3 class="fn" id="Notation-enum"><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> <div class="table"><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"><code>QDoubleValidator::StandardNotation</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">The string is written as a standard number (i.e. 0.015).</td></tr> <tr><td class="topAlign"><code>QDoubleValidator::ScientificNotation</code></td><td class="topAlign tblval"><code>1</code></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></div> <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" id="bottom-prop"><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> <div class="table"><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>(<i>double</i>)</td></tr> </table></div> <p><b>See also </b><a href="qdoublevalidator.html#setRange">setRange</a>().</p> <!-- @@@bottom --> <!-- $$$decimals-prop$$$decimals$$$setDecimalsint --> <h3 class="fn" id="decimals-prop"><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> <div class="table"><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>(<i>int</i>)</td></tr> </table></div> <p><b>See also </b><a href="qdoublevalidator.html#setRange">setRange</a>().</p> <!-- @@@decimals --> <!-- $$$notation-prop$$$notation$$$setNotationQDoubleValidator::Notation --> <h3 class="fn" id="notation-prop"><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> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> QDoubleValidator::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>(<i>QDoubleValidator::Notation</i>)</td></tr> </table></div> <p><b>See also </b><a href="qdoublevalidator.html#Notation-enum">Notation</a>.</p> <!-- @@@notation --> <!-- $$$top-prop$$$top$$$setTopdouble --> <h3 class="fn" id="top-prop"><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> <div class="table"><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>(<i>double</i>)</td></tr> </table></div> <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" id="QDoubleValidator"><a name="QDoubleValidator"></a>QDoubleValidator::<span class="name">QDoubleValidator</span>(<span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>parent</i> = nullptr)</h3> <p>Constructs a validator object with a <i>parent</i> object that accepts any double.</p> <!-- @@@QDoubleValidator --> <!-- $$$QDoubleValidator$$$QDoubleValidatordoubledoubleintQObject* --> <h3 class="fn" id="QDoubleValidator-1"><a name="QDoubleValidator-1"></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="../qtcore/qobject.html#QObject">QObject</a></span> *<i>parent</i> = nullptr)</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" id="dtor.QDoubleValidator"><a name="dtor.QDoubleValidator"></a><code>[virtual] </code>QDoubleValidator::<span class="name">~QDoubleValidator</span>()</h3> <p>Destroys the validator.</p> <!-- @@@~QDoubleValidator --> <!-- $$$setRange[overload1]$$$setRangedoubledoubleint --> <h3 class="fn" id="setRange"><a name="setRange"></a><code>[virtual] </code><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)</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" id="validate"><a name="validate"></a><code>[override virtual] </code><span class="type"><a href="qvalidator.html#State-enum">QValidator::State</a></span> QDoubleValidator::<span class="name">validate</span>(<span class="type"><a href="../qtcore/qstring.html">QString</a></span> &<i>input</i>, <span class="type">int</span> &<i>pos</i>) const</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. is empty.</p> <p>Returns <a href="qvalidator.html#State-enum">Invalid</a> if the <i>input</i> is not a double or with too many digits after the decimal point.</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> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2019 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br/> 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.<br/> 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. </p> </div> </body> </html>