<?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" /> <!-- qspinbox.cpp --> <title>Qt 4.8: QSpinBox 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>QSpinBox</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="#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="#details">Detailed Description</a></li> <li class="level2"><a href="#subclassing-qspinbox">Subclassing QSpinBox</a></li> </ul> </div> <h1 class="title">QSpinBox Class Reference</h1> <!-- $$$QSpinBox-brief --> <p>The QSpinBox class provides a spin box widget. <a href="#details">More...</a></p> <!-- @@@QSpinBox --> <pre class="cpp"> <span class="preprocessor">#include <QSpinBox></span></pre><p><b>Inherits: </b><a href="qabstractspinbox.html">QAbstractSpinBox</a>.</p> <ul> <li><a href="qspinbox-members.html">List of all members, including inherited members</a></li> <li><a href="qspinbox-qt3.html">Qt 3 support members</a></li> </ul> <a name="properties"></a> <h2>Properties</h2> <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#maximum-prop">maximum</a></b> : int</li> <li class="fn"><b><a href="qspinbox.html#minimum-prop">minimum</a></b> : int</li> <li class="fn"><b><a href="qspinbox.html#prefix-prop">prefix</a></b> : QString</li> </ul></td><td class="topAlign"><ul> <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> <ul> <li class="fn">11 properties inherited from <a href="qabstractspinbox.html#properties">QAbstractSpinBox</a></li> <li class="fn">58 properties inherited from <a href="qwidget.html#properties">QWidget</a></li> <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="qspinbox.html#QSpinBox">QSpinBox</a></b> ( QWidget * <i>parent</i> = 0 )</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#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#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> <ul> <li class="fn">28 public functions inherited from <a href="qabstractspinbox.html#public-functions">QAbstractSpinBox</a></li> <li class="fn">221 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li> <li class="fn">29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li> <li class="fn">13 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li> </ul> <a name="public-slots"></a> <h2>Public Slots</h2> <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> <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="qobject.html#public-slots">QObject</a></li> </ul> <a name="signals"></a> <h2>Signals</h2> <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-2">valueChanged</a></b> ( const QString & <i>text</i> )</td></tr> </table> <ul> <li class="fn">1 signal inherited from <a href="qabstractspinbox.html#signals">QAbstractSpinBox</a></li> <li class="fn">1 signal inherited from <a href="qwidget.html#signals">QWidget</a></li> <li class="fn">1 signal inherited from <a href="qobject.html#signals">QObject</a></li> </ul> <a name="protected-functions"></a> <h2>Protected Functions</h2> <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> <a name="reimplemented-protected-functions"></a> <h2>Reimplemented Protected Functions</h2> <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> )</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</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</td></tr> </table> <ul> <li class="fn">20 protected functions inherited from <a href="qabstractspinbox.html#protected-functions">QAbstractSpinBox</a></li> <li class="fn">37 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li> <li class="fn">8 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li> <li class="fn">1 protected function inherited from <a href="qpaintdevice.html#protected-functions">QPaintDevice</a></li> </ul> <h3>Additional Inherited Members</h3> <ul> <li class="fn">4 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li> <li class="fn">7 static public members inherited from <a href="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> </ul> <a name="details"></a> <!-- $$$QSpinBox-description --> <div class="descr"> <h2>Detailed Description</h2> <p>The QSpinBox class provides a spin box widget.</p> <p>QSpinBox 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>QSpinBox 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 QSpinBox emits the <a href="qspinbox.html#valueChanged">valueChanged</a>() signals. 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 QSpinBox 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 QSpinBox.</p> <table class="generic" width="100%"> <tr valign="top" class="odd"><td ><img src="images/windowsxp-spinbox.png" alt="Screenshot of a Windows XP spin box" /></td><td >A spin box shown in the <a href="gallery-windowsxp.html">Windows XP widget style</a>.</td></tr> <tr valign="top" class="even"><td ><img src="images/plastique-spinbox.png" alt="Screenshot of a Plastique spin box" /></td><td >A spin box shown in the <a href="gallery-plastique.html">Plastique widget style</a>.</td></tr> <tr valign="top" class="odd"><td ><img src="images/macintosh-spinbox.png" alt="Screenshot of a Macintosh spin box" /></td><td >A spin box shown in the <a href="gallery-macintosh.html">Macintosh widget style</a>.</td></tr> </table> <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 QSpinBox 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><a href="qspinbox.html#valueFromText">valueFromText</a>(<span class="keyword">const</span> <span class="type"><a href="qstring.html">QString</a></span> <span class="operator">&</span>text) <span class="keyword">const</span> { <span class="type"><a href="qregexp.html">QRegExp</a></span> regExp(tr(<span class="string">"(\\d+)(\\s*[xx]\\s*\\d+)?"</span>)); <span class="keyword">if</span> (regExp<span class="operator">.</span>exactMatch(text)) { <span class="keyword">return</span> regExp<span class="operator">.</span>cap(<span class="number">1</span>)<span class="operator">.</span>toInt(); } <span class="keyword">else</span> { <span class="keyword">return</span> <span class="number">0</span>; } } <span class="type"><a href="qstring.html">QString</a></span> IconSizeSpinBox<span class="operator">::</span><a href="qspinbox.html#textFromValue">textFromValue</a>(<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="widgets-icons.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="widgets-spinboxes.html">Spin Boxes Example</a>.</p> <!-- @@@QSpinBox --> <div class="prop"> <h2>Property Documentation</h2> <!-- $$$cleanText-prop$$$cleanText --> <h3 class="fn"><a name="cleanText-prop"></a><span class="name">cleanText</span> : const <span class="type"><a href="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> <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> <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 --> <!-- $$$maximum-prop$$$maximum$$$setMaximumint --> <h3 class="fn"><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 <a href="qspinbox.html#minimum-prop">minimum</a> 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> <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> <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"><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> <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> <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"><a name="prefix-prop"></a><span class="name">prefix</span> : <span class="type"><a href="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> <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> <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"><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> <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> <!-- @@@singleStep --> <!-- $$$suffix-prop$$$suffix$$$setSuffixconstQString& --> <h3 class="fn"><a name="suffix-prop"></a><span class="name">suffix</span> : <span class="type"><a href="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> <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> <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"><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.</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>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> <p><b>Notifier signal:</b></p> <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-2">valueChanged</a></b></span> ( const QString & <i>text</i> )</td></tr> </table> <!-- @@@value --> </div> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QSpinBox[overload1]$$$QSpinBoxQWidget* --> <h3 class="fn"><a name="QSpinBox"></a>QSpinBox::<span class="name">QSpinBox</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>parent</i> = 0 )</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 --> <!-- $$$event[overload1]$$$eventQEvent* --> <h3 class="fn"><a name="event"></a><span class="type">bool</span> QSpinBox::<span class="name">event</span> ( <span class="type"><a href="qevent.html">QEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qobject.html#event">QObject::event</a>().</p> <!-- @@@event --> <!-- $$$fixup[overload1]$$$fixupQString& --> <h3 class="fn"><a name="fixup"></a><span class="type">void</span> QSpinBox::<span class="name">fixup</span> ( <span class="type"><a href="qstring.html">QString</a></span> & <i>input</i> ) const<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qabstractspinbox.html#fixup">QAbstractSpinBox::fixup</a>().</p> <!-- @@@fixup --> <!-- $$$setRange[overload1]$$$setRangeintint --> <h3 class="fn"><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"> <a href="qspinbox.html#minimum-prop">setMinimum</a>(minimum); <a href="qspinbox.html#maximum-prop">setMaximum</a>(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"><a name="textFromValue"></a><span class="type"><a href="qstring.html">QString</a></span> QSpinBox::<span class="name">textFromValue</span> ( <span class="type">int</span> <i>value</i> ) const<tt> [virtual protected]</tt></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. 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="qlocale.html#groupSeparator">QLocale::groupSeparator</a>().</p> <!-- @@@textFromValue --> <!-- $$$validate[overload1]$$$validateQString&int& --> <h3 class="fn"><a name="validate"></a><span class="type"><a href="qvalidator.html#State-enum">QValidator::State</a></span> QSpinBox::<span class="name">validate</span> ( <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i>, <span class="type">int</span> & <i>pos</i> ) const<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qabstractspinbox.html#validate">QAbstractSpinBox::validate</a>().</p> <!-- @@@validate --> <!-- $$$valueChanged[overload1]$$$valueChangedint --> <h3 class="fn"><a name="valueChanged"></a><span class="type">void</span> QSpinBox::<span class="name">valueChanged</span> ( <span class="type">int</span> <i>i</i> )<tt> [signal]</tt></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> <!-- @@@valueChanged --> <!-- $$$valueChanged$$$valueChangedconstQString& --> <h3 class="fn"><a name="valueChanged-2"></a><span class="type">void</span> QSpinBox::<span class="name">valueChanged</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i> )<tt> [signal]</tt></h3> <p>This is an overloaded function.</p> <p>The new value is passed literally in <i>text</i> with no <a href="qspinbox.html#prefix-prop">prefix</a>() or <a href="qspinbox.html#suffix-prop">suffix</a>().</p> <!-- @@@valueChanged --> <!-- $$$valueFromText[overload1]$$$valueFromTextconstQString& --> <h3 class="fn"><a name="valueFromText"></a><span class="type">int</span> QSpinBox::<span class="name">valueFromText</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i> ) const<tt> [virtual protected]</tt></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 class="ft"> <span></span> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2013 Digia Plc and/or its subsidiaries. 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> Digia, Qt and their respective logos are trademarks of Digia Plc 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>