<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qspinbox.cpp --> <title>QSpinBox Class | Qt Widgets 5.9</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.9</td><td ><a href="qtwidgets-index.html">Qt Widgets</a></td><td ><a href="qtwidgets-module.html">C++ Classes</a></td><td >QSpinBox</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</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="#properties">Properties</a></li> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#public-slots">Public Slots</a></li> <li class="level1"><a href="#signals">Signals</a></li> <li class="level1"><a href="#protected-functions">Protected Functions</a></li> <li class="level1"><a href="#reimplemented-protected-functions">Reimplemented Protected Functions</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> <li class="level2"><a href="#subclassing-qspinbox">Subclassing QSpinBox</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">QSpinBox Class</h1> <!-- $$$QSpinBox-brief --> <p>The <a href="qspinbox.html">QSpinBox</a> class provides a spin box widget. <a href="#details">More...</a></p> <!-- @@@QSpinBox --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QSpinBox></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += widgets</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qabstractspinbox.html">QAbstractSpinBox</a></td></tr></table></div><ul> <li><a href="qspinbox-members.html">List of all members, including inherited members</a></li> </ul> <a name="properties"></a> <h2 id="properties">Properties</h2> <div class="table"><table class="propsummary"> <tr><td class="topAlign"><ul> <li class="fn"><b><a href="qspinbox.html#cleanText-prop">cleanText</a></b> : const QString</li> <li class="fn"><b><a href="qspinbox.html#displayIntegerBase-prop">displayIntegerBase</a></b> : int</li> <li class="fn"><b><a href="qspinbox.html#maximum-prop">maximum</a></b> : int</li> <li class="fn"><b><a href="qspinbox.html#minimum-prop">minimum</a></b> : int</li> </ul></td><td class="topAlign"><ul> <li class="fn"><b><a href="qspinbox.html#prefix-prop">prefix</a></b> : QString</li> <li class="fn"><b><a href="qspinbox.html#singleStep-prop">singleStep</a></b> : int</li> <li class="fn"><b><a href="qspinbox.html#suffix-prop">suffix</a></b> : QString</li> <li class="fn"><b><a href="qspinbox.html#value-prop">value</a></b> : int</li> </ul> </td></tr> </table></div> <ul> <li class="fn">12 properties inherited from <a href="qabstractspinbox.html#properties">QAbstractSpinBox</a></li> <li class="fn">59 properties inherited from <a href="qwidget.html#properties">QWidget</a></li> <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="qspinbox.html#QSpinBox">QSpinBox</a></b>(QWidget *<i>parent</i> = Q_NULLPTR)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#dtor.QSpinBox">~QSpinBox</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#cleanText-prop">cleanText</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#displayIntegerBase-prop">displayIntegerBase</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#maximum-prop">maximum</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#minimum-prop">minimum</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#prefix-prop">prefix</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#displayIntegerBase-prop">setDisplayIntegerBase</a></b>(int <i>base</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#maximum-prop">setMaximum</a></b>(int <i>max</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#minimum-prop">setMinimum</a></b>(int <i>min</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#prefix-prop">setPrefix</a></b>(const QString &<i>prefix</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#setRange">setRange</a></b>(int <i>minimum</i>, int <i>maximum</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#singleStep-prop">setSingleStep</a></b>(int <i>val</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#suffix-prop">setSuffix</a></b>(const QString &<i>suffix</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#singleStep-prop">singleStep</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#suffix-prop">suffix</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#value-prop">value</a></b>() const</td></tr> </table></div> <ul> <li class="fn">30 public functions inherited from <a href="qabstractspinbox.html#public-functions">QAbstractSpinBox</a></li> <li class="fn">214 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li> <li class="fn">32 public functions inherited from <a href="../qtcore/qobject.html#public-functions">QObject</a></li> <li class="fn">14 public functions inherited from <a href="../qtgui/qpaintdevice.html#public-functions">QPaintDevice</a></li> </ul> <a name="public-slots"></a> <h2 id="public-slots">Public Slots</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#value-prop">setValue</a></b>(int <i>val</i>)</td></tr> </table></div> <ul> <li class="fn">4 public slots inherited from <a href="qabstractspinbox.html#public-slots">QAbstractSpinBox</a></li> <li class="fn">19 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li> <li class="fn">1 public slot inherited from <a href="../qtcore/qobject.html#public-slots">QObject</a></li> </ul> <a name="signals"></a> <h2 id="signals">Signals</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#valueChanged">valueChanged</a></b>(int <i>i</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#valueChanged-1">valueChanged</a></b>(const QString &<i>text</i>)</td></tr> </table></div> <ul> <li class="fn">1 signal inherited from <a href="qabstractspinbox.html#signals">QAbstractSpinBox</a></li> <li class="fn">3 signals inherited from <a href="qwidget.html#signals">QWidget</a></li> <li class="fn">2 signals inherited from <a href="../qtcore/qobject.html#signals">QObject</a></li> </ul> <a name="protected-functions"></a> <h2 id="protected-functions">Protected Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> virtual QString </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#textFromValue">textFromValue</a></b>(int <i>value</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual int </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#valueFromText">valueFromText</a></b>(const QString &<i>text</i>) const</td></tr> </table></div> <a name="reimplemented-protected-functions"></a> <h2 id="reimplemented-protected-functions">Reimplemented Protected Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#event">event</a></b>(QEvent *<i>event</i>) override</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#fixup">fixup</a></b>(QString &<i>input</i>) const override</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual QValidator::State </td><td class="memItemRight bottomAlign"><b><a href="qspinbox.html#validate">validate</a></b>(QString &<i>text</i>, int &<i>pos</i>) const override</td></tr> </table></div> <ul> <li class="fn">20 protected functions inherited from <a href="qabstractspinbox.html#protected-functions">QAbstractSpinBox</a></li> <li class="fn">35 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li> <li class="fn">9 protected functions inherited from <a href="../qtcore/qobject.html#protected-functions">QObject</a></li> <li class="fn">1 protected function inherited from <a href="../qtgui/qpaintdevice.html#protected-functions">QPaintDevice</a></li> </ul> <h3>Additional Inherited Members</h3> <ul> <li class="fn">1 public variable inherited from <a href="../qtcore/qobject.html#public-variables">QObject</a></li> <li class="fn">5 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li> <li class="fn">10 static public members inherited from <a href="../qtcore/qobject.html#static-public-members">QObject</a></li> <li class="fn">1 protected slot inherited from <a href="qwidget.html#protected-slots">QWidget</a></li> <li class="fn">2 protected variables inherited from <a href="../qtcore/qobject.html#protected-variables">QObject</a></li> <li class="fn">1 protected type inherited from <a href="../qtgui/qpaintdevice.html#protected-variables">QPaintDevice</a></li> </ul> <a name="details"></a> <!-- $$$QSpinBox-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qspinbox.html">QSpinBox</a> class provides a spin box widget.</p> <p class="centerAlign"><img src="images/windows-spinbox.png" alt="" /></p><p><a href="qspinbox.html">QSpinBox</a> is designed to handle integers and discrete sets of values (e.g., month names); use <a href="qdoublespinbox.html">QDoubleSpinBox</a> for floating point values.</p> <p><a href="qspinbox.html">QSpinBox</a> allows the user to choose a value by clicking the up/down buttons or pressing up/down on the keyboard to increase/decrease the value currently displayed. The user can also type the value in manually. The spin box supports integer values but can be extended to use different strings with <a href="qspinbox.html#validate">validate</a>(), <a href="qspinbox.html#textFromValue">textFromValue</a>() and <a href="qspinbox.html#valueFromText">valueFromText</a>().</p> <p>Every time the value changes <a href="qspinbox.html">QSpinBox</a> emits two <a href="qspinbox.html#valueChanged">valueChanged</a>() signals, one providing an int and the other a <a href="../qtcore/qstring.html">QString</a>. The <a href="../qtcore/qstring.html">QString</a> overload provides the value with both <a href="qspinbox.html#prefix-prop">prefix</a>() and <a href="qspinbox.html#suffix-prop">suffix</a>(). The current value can be fetched with <a href="qspinbox.html#value-prop">value</a>() and set with <a href="qspinbox.html#value-prop">setValue</a>().</p> <p>Clicking the up/down buttons or using the keyboard accelerator's up and down arrows will increase or decrease the current value in steps of size <a href="qspinbox.html#singleStep-prop">singleStep</a>(). If you want to change this behaviour you can reimplement the virtual function <a href="qabstractspinbox.html#stepBy">stepBy</a>(). The minimum and maximum value and the step size can be set using one of the constructors, and can be changed later with <a href="qspinbox.html#minimum-prop">setMinimum</a>(), <a href="qspinbox.html#maximum-prop">setMaximum</a>() and <a href="qspinbox.html#singleStep-prop">setSingleStep</a>().</p> <p>Most spin boxes are directional, but <a href="qspinbox.html">QSpinBox</a> can also operate as a circular spin box, i.e. if the range is 0-99 and the current value is 99, clicking "up" will give 0 if <a href="qabstractspinbox.html#wrapping-prop">wrapping</a>() is set to true. Use <a href="qabstractspinbox.html#wrapping-prop">setWrapping</a>() if you want circular behavior.</p> <p>The displayed value can be prepended and appended with arbitrary strings indicating, for example, currency or the unit of measurement. See <a href="qspinbox.html#prefix-prop">setPrefix</a>() and <a href="qspinbox.html#suffix-prop">setSuffix</a>(). The text in the spin box is retrieved with <a href="qabstractspinbox.html#text-prop">text</a>() (which includes any <a href="qspinbox.html#prefix-prop">prefix</a>() and <a href="qspinbox.html#suffix-prop">suffix</a>()), or with <a href="qspinbox.html#cleanText-prop">cleanText</a>() (which has no <a href="qspinbox.html#prefix-prop">prefix</a>(), no <a href="qspinbox.html#suffix-prop">suffix</a>() and no leading or trailing whitespace).</p> <p>It is often desirable to give the user a special (often default) choice in addition to the range of numeric values. See <a href="qabstractspinbox.html#specialValueText-prop">setSpecialValueText</a>() for how to do this with <a href="qspinbox.html">QSpinBox</a>.</p> <a name="subclassing-qspinbox"></a> <h3 >Subclassing QSpinBox</h3> <p>If using <a href="qspinbox.html#prefix-prop">prefix</a>(), <a href="qspinbox.html#suffix-prop">suffix</a>(), and <a href="qabstractspinbox.html#specialValueText-prop">specialValueText</a>() don't provide enough control, you subclass <a href="qspinbox.html">QSpinBox</a> and reimplement <a href="qspinbox.html#valueFromText">valueFromText</a>() and <a href="qspinbox.html#textFromValue">textFromValue</a>(). For example, here's the code for a custom spin box that allows the user to enter icon sizes (e.g., "32 x 32"):</p> <pre class="cpp"> <span class="type">int</span> IconSizeSpinBox<span class="operator">::</span>valueFromText(<span class="keyword">const</span> <span class="type"><a href="../qtcore/qstring.html">QString</a></span> <span class="operator">&</span>text) <span class="keyword">const</span> { <span class="keyword">static</span> <span class="keyword">const</span> <span class="type"><a href="../qtcore/qregularexpression.html">QRegularExpression</a></span> regExp(tr(<span class="string">"(\\d+)(\\s*[xx]\\s*\\d+)?"</span>)); Q_ASSERT(regExp<span class="operator">.</span>isValid()); <span class="keyword">const</span> <span class="type"><a href="../qtcore/qregularexpressionmatch.html">QRegularExpressionMatch</a></span> match <span class="operator">=</span> regExp<span class="operator">.</span>match(text); <span class="keyword">if</span> (match<span class="operator">.</span>isValid()) <span class="keyword">return</span> match<span class="operator">.</span>captured(<span class="number">1</span>)<span class="operator">.</span>toInt(); <span class="keyword">return</span> <span class="number">0</span>; } <span class="type"><a href="../qtcore/qstring.html">QString</a></span> IconSizeSpinBox<span class="operator">::</span>textFromValue(<span class="type">int</span> value) <span class="keyword">const</span> { <span class="keyword">return</span> tr(<span class="string">"%1 x %1"</span>)<span class="operator">.</span>arg(value); } </pre> <p>See the <a href="qtwidgets-widgets-icons-example.html">Icons</a> example for the full source code.</p> </div> <p><b>See also </b><a href="qdoublespinbox.html">QDoubleSpinBox</a>, <a href="qdatetimeedit.html">QDateTimeEdit</a>, <a href="qslider.html">QSlider</a>, and <a href="qtwidgets-widgets-spinboxes-example.html">Spin Boxes Example</a>.</p> <!-- @@@QSpinBox --> <div class="prop"> <h2>Property Documentation</h2> <!-- $$$cleanText-prop$$$cleanText --> <h3 class="fn" id="cleanText-prop"><a name="cleanText-prop"></a><span class="name">cleanText</span> : const <span class="type"><a href="../qtcore/qstring.html">QString</a></span></h3> <p>This property holds the text of the spin box excluding any prefix, suffix, or leading or trailing whitespace.</p> <p><b>Access functions:</b></p> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>cleanText</b></span>() const</td></tr> </table></div> <p><b>See also </b><a href="qabstractspinbox.html#text-prop">text</a>, <a href="qspinbox.html#prefix-prop">QSpinBox::prefix</a>, and <a href="qspinbox.html#suffix-prop">QSpinBox::suffix</a>.</p> <!-- @@@cleanText --> <!-- $$$displayIntegerBase-prop$$$displayIntegerBase$$$setDisplayIntegerBaseint --> <h3 class="fn" id="displayIntegerBase-prop"><a name="displayIntegerBase-prop"></a><span class="name">displayIntegerBase</span> : <span class="type">int</span></h3> <p>This property holds the base used to display the value of the spin box</p> <p>The default displayIntegerBase value is 10.</p> <p>This property was introduced in Qt 5.2.</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>displayIntegerBase</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setDisplayIntegerBase</b></span>(int <i>base</i>)</td></tr> </table></div> <p><b>See also </b><a href="qspinbox.html#textFromValue">textFromValue</a>() and <a href="qspinbox.html#valueFromText">valueFromText</a>().</p> <!-- @@@displayIntegerBase --> <!-- $$$maximum-prop$$$maximum$$$setMaximumint --> <h3 class="fn" id="maximum-prop"><a name="maximum-prop"></a><span class="name">maximum</span> : <span class="type">int</span></h3> <p>This property holds the maximum value of the spin box</p> <p>When setting this property the minimum is adjusted if necessary, to ensure that the range remains valid.</p> <p>The default maximum value is 99.</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>maximum</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setMaximum</b></span>(int <i>max</i>)</td></tr> </table></div> <p><b>See also </b><a href="qspinbox.html#setRange">setRange</a>() and <a href="qabstractspinbox.html#specialValueText-prop">specialValueText</a>.</p> <!-- @@@maximum --> <!-- $$$minimum-prop$$$minimum$$$setMinimumint --> <h3 class="fn" id="minimum-prop"><a name="minimum-prop"></a><span class="name">minimum</span> : <span class="type">int</span></h3> <p>This property holds the minimum value of the spin box</p> <p>When setting this property the <a href="qspinbox.html#maximum-prop">maximum</a> is adjusted if necessary to ensure that the range remains valid.</p> <p>The default minimum value is 0.</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>minimum</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setMinimum</b></span>(int <i>min</i>)</td></tr> </table></div> <p><b>See also </b><a href="qspinbox.html#setRange">setRange</a>() and <a href="qabstractspinbox.html#specialValueText-prop">specialValueText</a>.</p> <!-- @@@minimum --> <!-- $$$prefix-prop$$$prefix$$$setPrefixconstQString& --> <h3 class="fn" id="prefix-prop"><a name="prefix-prop"></a><span class="name">prefix</span> : <span class="type"><a href="../qtcore/qstring.html">QString</a></span></h3> <p>This property holds the spin box's prefix</p> <p>The prefix is prepended to the start of the displayed value. Typical use is to display a unit of measurement or a currency symbol. For example:</p> <pre class="cpp"> sb<span class="operator">-</span><span class="operator">></span>setPrefix(<span class="string">"$"</span>); </pre> <p>To turn off the prefix display, set this property to an empty string. The default is no prefix. The prefix is not displayed when <a href="qspinbox.html#value-prop">value</a>() == <a href="qspinbox.html#minimum-prop">minimum</a>() and <a href="qabstractspinbox.html#specialValueText-prop">specialValueText</a>() is set.</p> <p>If no prefix is set, prefix() returns an empty string.</p> <p><b>Access functions:</b></p> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>prefix</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setPrefix</b></span>(const QString &<i>prefix</i>)</td></tr> </table></div> <p><b>See also </b><a href="qspinbox.html#suffix-prop">suffix</a>(), <a href="qspinbox.html#suffix-prop">setSuffix</a>(), <a href="qabstractspinbox.html#specialValueText-prop">specialValueText</a>(), and <a href="qabstractspinbox.html#specialValueText-prop">setSpecialValueText</a>().</p> <!-- @@@prefix --> <!-- $$$singleStep-prop$$$singleStep$$$setSingleStepint --> <h3 class="fn" id="singleStep-prop"><a name="singleStep-prop"></a><span class="name">singleStep</span> : <span class="type">int</span></h3> <p>This property holds the step value</p> <p>When the user uses the arrows to change the spin box's value the value will be incremented/decremented by the amount of the singleStep. The default value is 1. Setting a singleStep value of less than 0 does nothing.</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>singleStep</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setSingleStep</b></span>(int <i>val</i>)</td></tr> </table></div> <!-- @@@singleStep --> <!-- $$$suffix-prop$$$suffix$$$setSuffixconstQString& --> <h3 class="fn" id="suffix-prop"><a name="suffix-prop"></a><span class="name">suffix</span> : <span class="type"><a href="../qtcore/qstring.html">QString</a></span></h3> <p>This property holds the suffix of the spin box</p> <p>The suffix is appended to the end of the displayed value. Typical use is to display a unit of measurement or a currency symbol. For example:</p> <pre class="cpp"> sb<span class="operator">-</span><span class="operator">></span>setSuffix(<span class="string">" km"</span>); </pre> <p>To turn off the suffix display, set this property to an empty string. The default is no suffix. The suffix is not displayed for the <a href="qspinbox.html#minimum-prop">minimum</a>() if <a href="qabstractspinbox.html#specialValueText-prop">specialValueText</a>() is set.</p> <p>If no suffix is set, suffix() returns an empty string.</p> <p><b>Access functions:</b></p> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>suffix</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setSuffix</b></span>(const QString &<i>suffix</i>)</td></tr> </table></div> <p><b>See also </b><a href="qspinbox.html#prefix-prop">prefix</a>(), <a href="qspinbox.html#prefix-prop">setPrefix</a>(), <a href="qabstractspinbox.html#specialValueText-prop">specialValueText</a>(), and <a href="qabstractspinbox.html#specialValueText-prop">setSpecialValueText</a>().</p> <!-- @@@suffix --> <!-- $$$value-prop$$$value$$$setValueint$$$valueChangedint$$$valueChangedconstQString& --> <h3 class="fn" id="value-prop"><a name="value-prop"></a><span class="name">value</span> : <span class="type">int</span></h3> <p>This property holds the value of the spin box</p> <p>setValue() will emit <a href="qspinbox.html#valueChanged">valueChanged</a>() if the new value is different from the old one. The value property has a second notifier signal which includes the spin box's prefix and suffix.</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>value</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setValue</b></span>(int <i>val</i>)</td></tr> </table></div> <p><b>Notifier signal:</b></p> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="qspinbox.html#valueChanged">valueChanged</a></b></span>(int <i>i</i>)</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="qspinbox.html#valueChanged-1">valueChanged</a></b></span>(const QString &<i>text</i>)</td></tr> </table></div> <!-- @@@value --> </div> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QSpinBox[overload1]$$$QSpinBoxQWidget* --> <h3 class="fn" id="QSpinBox"><a name="QSpinBox"></a>QSpinBox::<span class="name">QSpinBox</span>(<span class="type"><a href="qwidget.html#QWidget">QWidget</a></span> *<i>parent</i> = Q_NULLPTR)</h3> <p>Constructs a spin box with 0 as minimum value and 99 as maximum value, a step value of 1. The value is initially set to 0. It is parented to <i>parent</i>.</p> <p><b>See also </b><a href="qspinbox.html#minimum-prop">setMinimum</a>(), <a href="qspinbox.html#maximum-prop">setMaximum</a>(), and <a href="qspinbox.html#singleStep-prop">setSingleStep</a>().</p> <!-- @@@QSpinBox --> <!-- $$$~QSpinBox[overload1]$$$~QSpinBox --> <h3 class="fn" id="dtor.QSpinBox"><a name="dtor.QSpinBox"></a>QSpinBox::<span class="name">~QSpinBox</span>()</h3> <p>Destructor.</p> <!-- @@@~QSpinBox --> <!-- $$$event[overload1]$$$eventQEvent* --> <h3 class="fn" id="event"><a name="event"></a><code>[override virtual protected] </code><span class="type">bool</span> QSpinBox::<span class="name">event</span>(<span class="type"><a href="../qtcore/qevent.html">QEvent</a></span> *<i>event</i>)</h3> <p>Reimplemented from <a href="../qtcore/qobject.html#event">QObject::event</a>().</p> <!-- @@@event --> <!-- $$$fixup[overload1]$$$fixupQString& --> <h3 class="fn" id="fixup"><a name="fixup"></a><code>[override virtual protected] </code><span class="type">void</span> QSpinBox::<span class="name">fixup</span>(<span class="type"><a href="../qtcore/qstring.html">QString</a></span> &<i>input</i>) const</h3> <p>Reimplemented from <a href="qabstractspinbox.html#fixup">QAbstractSpinBox::fixup</a>().</p> <!-- @@@fixup --> <!-- $$$setRange[overload1]$$$setRangeintint --> <h3 class="fn" id="setRange"><a name="setRange"></a><span class="type">void</span> QSpinBox::<span class="name">setRange</span>(<span class="type">int</span> <i>minimum</i>, <span class="type">int</span> <i>maximum</i>)</h3> <p>Convenience function to set the <i>minimum</i>, and <i>maximum</i> values with a single function call.</p> <pre class="cpp"> setRange(minimum<span class="operator">,</span> maximum); </pre> <p>is equivalent to:</p> <pre class="cpp"> setMinimum(minimum); setMaximum(maximum); </pre> <p><b>See also </b><a href="qspinbox.html#minimum-prop">minimum</a> and <a href="qspinbox.html#maximum-prop">maximum</a>.</p> <!-- @@@setRange --> <!-- $$$textFromValue[overload1]$$$textFromValueint --> <h3 class="fn" id="textFromValue"><a name="textFromValue"></a><code>[virtual protected] </code><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QSpinBox::<span class="name">textFromValue</span>(<span class="type">int</span> <i>value</i>) const</h3> <p>This virtual function is used by the spin box whenever it needs to display the given <i>value</i>. The default implementation returns a string containing <i>value</i> printed in the standard way using <a href="qwidget.html#locale-prop">QWidget::locale</a>().toString(), but with the thousand separator removed unless <a href="qabstractspinbox.html#showGroupSeparator-prop">setGroupSeparatorShown</a>() is set. Reimplementations may return anything. (See the example in the detailed description.)</p> <p>Note: <a href="qspinbox.html">QSpinBox</a> does not call this function for <a href="qabstractspinbox.html#specialValueText-prop">specialValueText</a>() and that neither <a href="qspinbox.html#prefix-prop">prefix</a>() nor <a href="qspinbox.html#suffix-prop">suffix</a>() should be included in the return value.</p> <p>If you reimplement this, you may also need to reimplement <a href="qspinbox.html#valueFromText">valueFromText</a>() and <a href="qspinbox.html#validate">validate</a>()</p> <p><b>See also </b><a href="qspinbox.html#valueFromText">valueFromText</a>(), <a href="qspinbox.html#validate">validate</a>(), and <a href="../qtcore/qlocale.html#groupSeparator">QLocale::groupSeparator</a>().</p> <!-- @@@textFromValue --> <!-- $$$validate[overload1]$$$validateQString&int& --> <h3 class="fn" id="validate"><a name="validate"></a><code>[override virtual protected] </code><span class="type"><a href="../qtgui/qvalidator.html#State-enum">QValidator::State</a></span> QSpinBox::<span class="name">validate</span>(<span class="type"><a href="../qtcore/qstring.html">QString</a></span> &<i>text</i>, <span class="type">int</span> &<i>pos</i>) const</h3> <p>Reimplemented from <a href="qabstractspinbox.html#validate">QAbstractSpinBox::validate</a>().</p> <!-- @@@validate --> <!-- $$$valueChanged --> <h3 class="fn" id="valueChanged"><a name="valueChanged"></a><code>[signal] </code><span class="type">void</span> QSpinBox::<span class="name">valueChanged</span>(<span class="type">int</span> <i>i</i>)</h3> <p>This signal is emitted whenever the spin box's value is changed. The new value's integer value is passed in <i>i</i>.</p> <p><b>Note:</b> Signal <i>valueChanged</i> is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:<pre class="cpp"> connect(spinBox<span class="operator">,</span> <span class="keyword">static_cast</span><span class="operator"><</span><span class="type">void</span>(<span class="type"><a href="qspinbox.html#QSpinBox">QSpinBox</a></span><span class="operator">::</span><span class="operator">*</span>)(<span class="type">int</span>)<span class="operator">></span>(<span class="operator">&</span><span class="type"><a href="qspinbox.html#QSpinBox">QSpinBox</a></span><span class="operator">::</span>valueChanged)<span class="operator">,</span> <span class="operator">[</span><span class="operator">=</span><span class="operator">]</span>(<span class="type">int</span> i){ <span class="comment">/* ... */</span> }); </pre> <p><b>Note:</b> Notifier signal for property <a href="qspinbox.html#value-prop">value</a>. </p><!-- @@@valueChanged --> <!-- $$$valueChanged --> <h3 class="fn" id="valueChanged-1"><a name="valueChanged-1"></a><code>[signal] </code><span class="type">void</span> QSpinBox::<span class="name">valueChanged</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &<i>text</i>)</h3> <p>This is an overloaded function.</p> <p>The new value is passed in <i>text</i> with <a href="qspinbox.html#prefix-prop">prefix</a>() and <a href="qspinbox.html#suffix-prop">suffix</a>().</p> <p><b>Note:</b> Signal <i>valueChanged</i> is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:<pre class="cpp"> connect(spinBox<span class="operator">,</span> <span class="keyword">static_cast</span><span class="operator"><</span><span class="type">void</span>(<span class="type"><a href="qspinbox.html#QSpinBox">QSpinBox</a></span><span class="operator">::</span><span class="operator">*</span>)(<span class="keyword">const</span> <span class="type"><a href="../qtcore/qstring.html">QString</a></span> <span class="operator">&</span>)<span class="operator">></span>(<span class="operator">&</span><span class="type"><a href="qspinbox.html#QSpinBox">QSpinBox</a></span><span class="operator">::</span>valueChanged)<span class="operator">,</span> <span class="operator">[</span><span class="operator">=</span><span class="operator">]</span>(<span class="keyword">const</span> <span class="type"><a href="../qtcore/qstring.html">QString</a></span> <span class="operator">&</span>text){ <span class="comment">/* ... */</span> }); </pre> <p><b>Note:</b> Notifier signal for property <a href="qspinbox.html#value-prop">value</a>. </p><!-- @@@valueChanged --> <!-- $$$valueFromText[overload1]$$$valueFromTextconstQString& --> <h3 class="fn" id="valueFromText"><a name="valueFromText"></a><code>[virtual protected] </code><span class="type">int</span> QSpinBox::<span class="name">valueFromText</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &<i>text</i>) const</h3> <p>This virtual function is used by the spin box whenever it needs to interpret <i>text</i> entered by the user as a value.</p> <p>Subclasses that need to display spin box values in a non-numeric way need to reimplement this function.</p> <p>Note: <a href="qspinbox.html">QSpinBox</a> handles <a href="qabstractspinbox.html#specialValueText-prop">specialValueText</a>() separately; this function is only concerned with the other values.</p> <p><b>See also </b><a href="qspinbox.html#textFromValue">textFromValue</a>() and <a href="qspinbox.html#validate">validate</a>().</p> <!-- @@@valueFromText --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2017 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>