<class name="QSpinBox" doc="/** <p>The <a href="QSpinBox.html#QSpinBox(com.trolltech.qt.gui.QWidget)"><tt>QSpinBox</tt></a> class provides a spin box widget.</p> <p><a href="QSpinBox.html#QSpinBox(com.trolltech.qt.gui.QWidget)"><tt>QSpinBox</tt></a> is designed to handle integers and discrete sets of values (e.g&#x2e;, month names); use <a href="QDoubleSpinBox.html"><tt>QDoubleSpinBox</tt></a> for floating point values.</p> <p><a href="QSpinBox.html#QSpinBox(com.trolltech.qt.gui.QWidget)"><tt>QSpinBox</tt></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(com.trolltech.qt.gui.QValidator.QValidationData)"><tt>validate</tt></a>, <a href="QSpinBox.html#textFromValue(int)"><tt>textFromValue</tt></a> and <a href="QSpinBox.html#valueFromText(java.lang.String)"><tt>valueFromText</tt></a>.</p> <p>Every time the value changes <a href="QSpinBox.html#QSpinBox(com.trolltech.qt.gui.QWidget)"><tt>QSpinBox</tt></a> emits the <a href="QSpinBox.html#valueChanged(int)"><tt>valueChanged</tt></a> signals. The current value can be fetched with <a href="QSpinBox.html#value()"><tt>value</tt></a> and set with <a href="QSpinBox.html#setValue(int)"><tt>setValue</tt></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()"><tt>singleStep</tt></a>. If you want to change this behaviour you can reimplement the virtual function <a href="QAbstractSpinBox.html#stepBy(int)"><tt>stepBy</tt></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#setMinimum(int)"><tt>setMinimum</tt></a>, <a href="QSpinBox.html#setMaximum(int)"><tt>setMaximum</tt></a> and <a href="QSpinBox.html#setSingleStep(int)"><tt>setSingleStep</tt></a>.</p> <p>Most spin boxes are directional, but <a href="QSpinBox.html#QSpinBox(com.trolltech.qt.gui.QWidget)"><tt>QSpinBox</tt></a> can also operate as a circular spin box, i.e&#x2e; if the range is 0-99 and the current value is 99, clicking &quot;up&quot; will give 0 if <a href="QAbstractSpinBox.html#wrapping()"><tt>wrapping</tt></a> is set to true. Use <a href="QAbstractSpinBox.html#setWrapping(boolean)"><tt>setWrapping</tt></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#setPrefix(java.lang.String)"><tt>setPrefix</tt></a> and <a href="QSpinBox.html#setSuffix(java.lang.String)"><tt>setSuffix</tt></a>. The text in the spin box is retrieved with <a href="QAbstractSpinBox.html#text()"><tt>text</tt></a> (which includes any <a href="QSpinBox.html#prefix()"><tt>prefix</tt></a> and <a href="QSpinBox.html#suffix()"><tt>suffix</tt></a>), or with <a href="QSpinBox.html#cleanText()"><tt>cleanText</tt></a> (which has no <a href="QSpinBox.html#prefix()"><tt>prefix</tt></a>, no <a href="QSpinBox.html#suffix()"><tt>suffix</tt></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#setSpecialValueText(java.lang.String)"><tt>setSpecialValueText</tt></a> for how to do this with <a href="QSpinBox.html#QSpinBox(com.trolltech.qt.gui.QWidget)"><tt>QSpinBox</tt></a>.</p> <p><table width="100%" align="center" cellpadding="2" cellspacing="1" border="0"> <tr valign="top" class="odd"><td><img src="%2E%2E/images/windowsxp-spinbox.png" alt="Screenshot of a Windows XP spin box" /></td><td>A spin box shown in the <a href="%2E%2E/gallery-windowsxp.html">Windows XP widget style</tt></a>.</td></tr> <tr valign="top" class="even"><td><img src="%2E%2E/images/plastique-spinbox.png" alt="Screenshot of a Plastique spin box" /></td><td>A spin box shown in the <a href="%2E%2E/gallery-plastique.html">Plastique widget style</tt></a>.</td></tr> <tr valign="top" class="odd"><td><img src="%2E%2E/images/macintosh-spinbox.png" alt="Screenshot of a Macintosh spin box" /></td><td>A spin box shown in the <a href="%2E%2E/gallery-macintosh.html">Macintosh widget style</tt></a>.</td></tr> </table></p> <a name="subclassing-qspinbox"></a> <h3>Subclassing QSpinBox</h3> <p>If using <a href="QSpinBox.html#prefix()"><tt>prefix</tt></a>, <a href="QSpinBox.html#suffix()"><tt>suffix</tt></a>, and <a href="QAbstractSpinBox.html#specialValueText()"><tt>specialValueText</tt></a> don't provide enough control, you subclass <a href="QSpinBox.html#QSpinBox(com.trolltech.qt.gui.QWidget)"><tt>QSpinBox</tt></a> and reimplement <a href="QSpinBox.html#valueFromText(java.lang.String)"><tt>valueFromText</tt></a> and <a href="QSpinBox.html#textFromValue(int)"><tt>textFromValue</tt></a>. For example, here's the code for a custom spin box that allows the user to enter icon sizes (e.g&#x2e;, &quot;32 x 32&quot;):</p> <pre> int IconSizeSpinBox::valueFromText(const QString &amp;text) const { QRegExp regExp(tr(&quot;(\\d+)(\\s*[xx]\\s*\\d+)?&quot;)); if (regExp.exactMatch(text)) { return regExp.cap(1).toInt(); } else { return 0; } } QString IconSizeSpinBox::textFromValue(int value) const { return tr(&quot;%1 x %1&quot;).arg(value); }</pre> <p>See the Icons</tt> example for the full source code.</p> @see <a href="QDoubleSpinBox.html"><tt>QDoubleSpinBox</tt></a> @see <a href="QDateTimeEdit.html"><tt>QDateTimeEdit</tt></a> @see <a href="QSlider.html"><tt>QSlider</tt></a> @see <a href="%2E%2E/qtjambi-spinboxes.html">Spin Boxes Example</tt></a> */"> <signal name="protected final void customContextMenuRequested(com.trolltech.qt.core.QPoint pos)" doc="/** <p>This signal is emitted when the widget's <a href="QWidget.html#contextMenuPolicy()"><tt>contextMenuPolicy</tt></a> is Qt::CustomContextMenu, and the user has requested a context menu on the widget. The position <tt>pos</tt> is the position of the context menu event that the widget receives. Normally this is in widget coordinates. The exception to this rule is <a href="QAbstractScrollArea.html"><tt>QAbstractScrollArea</tt></a> and its subclasses that map the context menu event to coordinates of the viewport()</tt> .</p> <dl> <dt><b>Compatible Slot Signatures:</b></dt> <dd><tt>void mySlot(com.trolltech.qt.core.QPoint pos)</tt></dd> <dd><tt>void mySlot()</tt></dd> </dl> <dl> <dt><b>See Also:</b></dt> <dd><a href="QWidget.html#mapToGlobal(com.trolltech.qt.core.QPoint)"><tt>mapToGlobal</tt></a>, <a href="QMenu.html"><tt>QMenu</tt></a>, <a href="QWidget.html#contextMenuPolicy()"><tt>contextMenuPolicy</tt></a></dd> </dl> */"/> <signal name="protected final void editingFinished()" doc="/** <p>This signal is emitted editing is finished. This happens when the spinbox loses focus and when enter is pressed.</p> <dl> <dt><b>Compatible Slot Signature:</b></dt> <dd><tt>void mySlot()</tt></dd> </dl> */"/> <signal name="protected final void valueChanged(int arg__1)" doc="/** <p>This signal is emitted whenever the spin box's value is changed. The new value's integer value is passed in <tt>arg__1</tt>.</p> <dl> <dt><b>Compatible Slot Signatures:</b></dt> <dd><tt>void mySlot(int arg__1)</tt></dd> <dd><tt>void mySlot()</tt></dd> </dl> */"/> <signal name="protected final void valueStringChanged(java.lang.String arg__1)" doc="/** <p>The new value is passed literally in <tt>arg__1</tt> with no <a href="QSpinBox.html#prefix()"><tt>prefix</tt></a> or <a href="QSpinBox.html#suffix()"><tt>suffix</tt></a>.</p> <dl> <dt><b>Compatible Slot Signatures:</b></dt> <dd><tt>void mySlot(java.lang.String arg__1)</tt></dd> <dd><tt>void mySlot()</tt></dd> </dl> */"/> <method name="public QSpinBox(com.trolltech.qt.gui.QWidget parent)" doc="/** <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 <tt>parent</tt>.</p> @see <a href="QSpinBox.html#setMinimum(int)"><tt>setMinimum</tt></a> @see <a href="QSpinBox.html#setMaximum(int)"><tt>setMaximum</tt></a> @see <a href="QSpinBox.html#setSingleStep(int)"><tt>setSingleStep</tt></a> */"/> <method name="public QSpinBox()" doc="/** <p>Equivalent to <a href="QSpinBox.html#QSpinBox(com.trolltech.qt.gui.QWidget)"><tt>QSpinBox</tt></a>(0). */"/> <method name="public final java.lang.String cleanText()" doc="/** <p>Returns the text of the spin box excluding any prefix, suffix, or leading or trailing whitespace..</p> @see <a href="QAbstractSpinBox.html#text()">text</tt></a> @see <tt>QSpinBox::prefix</tt> @see <tt>QSpinBox::suffix</tt> */"/> <method name="public final int maximum()" doc="/** <p>Returns the maximum value of the spin box.</p> <p>When setting this property the <a href="QSpinBox.html#minimum()">minimum</tt></a> is adjusted if necessary, to ensure that the range remains valid.</p> <p>The default maximum value is 99.</p> @see <a href="QSpinBox.html#setMaximum(int)"><tt>setMaximum</tt></a> @see <a href="QSpinBox.html#setRange(int, int)"><tt>setRange</tt></a> @see <a href="QAbstractSpinBox.html#specialValueText()"><tt>specialValueText</tt></a> */"/> <method name="public final int minimum()" doc="/** <p>Returns the minimum value of the spin box.</p> <p>When setting this property the <a href="QSpinBox.html#maximum()">maximum</tt></a> is adjusted if necessary to ensure that the range remains valid.</p> <p>The default minimum value is 0.</p> @see <a href="QSpinBox.html#setMinimum(int)"><tt>setMinimum</tt></a> @see <a href="QSpinBox.html#setRange(int, int)"><tt>setRange</tt></a> @see <a href="QAbstractSpinBox.html#specialValueText()"><tt>specialValueText</tt></a> */"/> <method name="public final java.lang.String prefix()" doc="/** <p>Returns 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> sb-&gt;setPrefix(&quot;$&quot;);</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()"><tt>value</tt></a> == <a href="QSpinBox.html#minimum()"><tt>minimum</tt></a> and <a href="QAbstractSpinBox.html#specialValueText()"><tt>specialValueText</tt></a> is set.</p> <p>If no prefix is set, <a href="QSpinBox.html#prefix()"><tt>prefix</tt></a> returns an empty string.</p> @see <a href="QSpinBox.html#setPrefix(java.lang.String)"><tt>setPrefix</tt></a> @see <a href="QSpinBox.html#suffix()"><tt>suffix</tt></a> @see <a href="QSpinBox.html#setSuffix(java.lang.String)"><tt>setSuffix</tt></a> @see <a href="QAbstractSpinBox.html#specialValueText()"><tt>specialValueText</tt></a> @see <a href="QAbstractSpinBox.html#setSpecialValueText(java.lang.String)"><tt>setSpecialValueText</tt></a> */"/> <method name="public final void setMaximum(int max)" doc="/** <p>Sets the maximum value of the spin box to <tt>max</tt>.</p> <p>When setting this property the <a href="QSpinBox.html#minimum()">minimum</tt></a> is adjusted if necessary, to ensure that the range remains valid.</p> <p>The default maximum value is 99.</p> @see <a href="QSpinBox.html#maximum()"><tt>maximum</tt></a> @see <a href="QSpinBox.html#setRange(int, int)"><tt>setRange</tt></a> @see <a href="QAbstractSpinBox.html#specialValueText()"><tt>specialValueText</tt></a> */"/> <method name="public final void setMinimum(int min)" doc="/** <p>Sets the minimum value of the spin box to <tt>min</tt>.</p> <p>When setting this property the <a href="QSpinBox.html#maximum()">maximum</tt></a> is adjusted if necessary to ensure that the range remains valid.</p> <p>The default minimum value is 0.</p> @see <a href="QSpinBox.html#minimum()"><tt>minimum</tt></a> @see <a href="QSpinBox.html#setRange(int, int)"><tt>setRange</tt></a> @see <a href="QAbstractSpinBox.html#specialValueText()"><tt>specialValueText</tt></a> */"/> <method name="public final void setPrefix(java.lang.String prefix)" doc="/** <p>Sets the spin box's prefix to <tt>prefix</tt>.</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> sb-&gt;setPrefix(&quot;$&quot;);</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()"><tt>value</tt></a> == <a href="QSpinBox.html#minimum()"><tt>minimum</tt></a> and <a href="QAbstractSpinBox.html#specialValueText()"><tt>specialValueText</tt></a> is set.</p> <p>If no prefix is set, <a href="QSpinBox.html#prefix()"><tt>prefix</tt></a> returns an empty string.</p> @see <a href="QSpinBox.html#prefix()"><tt>prefix</tt></a> @see <a href="QSpinBox.html#suffix()"><tt>suffix</tt></a> @see <a href="QSpinBox.html#setSuffix(java.lang.String)"><tt>setSuffix</tt></a> @see <a href="QAbstractSpinBox.html#specialValueText()"><tt>specialValueText</tt></a> @see <a href="QAbstractSpinBox.html#setSpecialValueText(java.lang.String)"><tt>setSpecialValueText</tt></a> */"/> <method name="public final void setRange(int min, int max)" doc="/** <p>Convenience function to set the <tt>min</tt>, and <tt>max</tt> values with a single function call.</p> <pre> setRange(minimum, maximum);</pre> <p>is equivalent to:</p> <pre> setMinimum(minimum); setMaximum(maximum);</pre> @see <a href="QSpinBox.html#minimum()">minimum</tt></a> @see <a href="QSpinBox.html#maximum()">maximum</tt></a> */"/> <method name="public final void setSingleStep(int val)" doc="/** <p>Sets the step value to <tt>val</tt>.</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 <a href="QSpinBox.html#singleStep()"><tt>singleStep</tt></a>. The default value is 1. Setting a <a href="QSpinBox.html#singleStep()"><tt>singleStep</tt></a> value of less than 0 does nothing.</p> @see <a href="QSpinBox.html#singleStep()"><tt>singleStep</tt></a> */"/> <method name="public final void setSuffix(java.lang.String suffix)" doc="/** <p>Sets the suffix of the spin box to <tt>suffix</tt>.</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> sb-&gt;setSuffix(&quot; km&quot;);</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()"><tt>minimum</tt></a> if <a href="QAbstractSpinBox.html#specialValueText()"><tt>specialValueText</tt></a> is set.</p> <p>If no suffix is set, <a href="QSpinBox.html#suffix()"><tt>suffix</tt></a> returns an empty string.</p> @see <a href="QSpinBox.html#suffix()"><tt>suffix</tt></a> @see <a href="QSpinBox.html#prefix()"><tt>prefix</tt></a> @see <a href="QSpinBox.html#setPrefix(java.lang.String)"><tt>setPrefix</tt></a> @see <a href="QAbstractSpinBox.html#specialValueText()"><tt>specialValueText</tt></a> @see <a href="QAbstractSpinBox.html#setSpecialValueText(java.lang.String)"><tt>setSpecialValueText</tt></a> */"/> <method name="public final void setValue(int val)" doc="/** <p>Sets the value of the spin box to <tt>val</tt>.</p> <p><a href="QSpinBox.html#setValue(int)"><tt>setValue</tt></a> will emit <a href="QSpinBox.html#valueChanged(int)"><tt>valueChanged</tt></a> if the new value is different from the old one.</p> @see <a href="QSpinBox.html#value()"><tt>value</tt></a> */"/> <method name="public final int singleStep()" doc="/** <p>Returns 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 <a href="QSpinBox.html#singleStep()"><tt>singleStep</tt></a>. The default value is 1. Setting a <a href="QSpinBox.html#singleStep()"><tt>singleStep</tt></a> value of less than 0 does nothing.</p> @see <a href="QSpinBox.html#setSingleStep(int)"><tt>setSingleStep</tt></a> */"/> <method name="public final java.lang.String suffix()" doc="/** <p>Returns 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> sb-&gt;setSuffix(&quot; km&quot;);</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()"><tt>minimum</tt></a> if <a href="QAbstractSpinBox.html#specialValueText()"><tt>specialValueText</tt></a> is set.</p> <p>If no suffix is set, <a href="QSpinBox.html#suffix()"><tt>suffix</tt></a> returns an empty string.</p> @see <a href="QSpinBox.html#setSuffix(java.lang.String)"><tt>setSuffix</tt></a> @see <a href="QSpinBox.html#prefix()"><tt>prefix</tt></a> @see <a href="QSpinBox.html#setPrefix(java.lang.String)"><tt>setPrefix</tt></a> @see <a href="QAbstractSpinBox.html#specialValueText()"><tt>specialValueText</tt></a> @see <a href="QAbstractSpinBox.html#setSpecialValueText(java.lang.String)"><tt>setSpecialValueText</tt></a> */"/> <method name="public final int value()" doc="/** <p>Returns the value of the spin box.</p> <p><a href="QSpinBox.html#setValue(int)"><tt>setValue</tt></a> will emit <a href="QSpinBox.html#valueChanged(int)"><tt>valueChanged</tt></a> if the new value is different from the old one.</p> @see <a href="QSpinBox.html#setValue(int)"><tt>setValue</tt></a> */"/> <method name="public boolean event(com.trolltech.qt.core.QEvent event)" doc="/** <p>This function is reimplemented for internal reasons.</p> */"/> <method name="public java.lang.String fixup(java.lang.String str)" doc="/** <p>This function is reimplemented for internal reasons.</p> */"/> <method name="protected java.lang.String textFromValue(int val)" doc="/** <p>This virtual function is used by the spin box whenever it needs to display the given <tt>val</tt>. The default implementation returns a string containing <tt>val</tt> printed in the standard way using QLocale().toString(). Reimplementations may return anything. (See the example in the detailed description.)</p> <p>Note: <a href="QSpinBox.html#QSpinBox(com.trolltech.qt.gui.QWidget)"><tt>QSpinBox</tt></a> does not call this function for <a href="QAbstractSpinBox.html#specialValueText()"><tt>specialValueText</tt></a> and that neither <a href="QSpinBox.html#prefix()"><tt>prefix</tt></a> nor <a href="QSpinBox.html#suffix()"><tt>suffix</tt></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(java.lang.String)"><tt>valueFromText</tt></a> and <a href="QSpinBox.html#validate(com.trolltech.qt.gui.QValidator.QValidationData)"><tt>validate</tt></a></p> @see <a href="QSpinBox.html#valueFromText(java.lang.String)"><tt>valueFromText</tt></a> @see <a href="QSpinBox.html#validate(com.trolltech.qt.gui.QValidator.QValidationData)"><tt>validate</tt></a> */"/> <method name="public com.trolltech.qt.gui.QValidator.State validate(com.trolltech.qt.gui.QValidator.QValidationData input)" doc="/** <p>Equivalent to <a href="QSpinBox.html#validate(com.trolltech.qt.gui.QValidator.QValidationData)">validate</tt></a>(<tt>input</tt>, ). */"/> <method name="protected int valueFromText(java.lang.String text)" doc="/** <p>This virtual function is used by the spin box whenever it needs to interpret <tt>text</tt> 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(com.trolltech.qt.gui.QWidget)"><tt>QSpinBox</tt></a> handles <a href="QAbstractSpinBox.html#specialValueText()"><tt>specialValueText</tt></a> separately; this function is only concerned with the other values.</p> @see <a href="QSpinBox.html#textFromValue(int)"><tt>textFromValue</tt></a> @see <a href="QSpinBox.html#validate(com.trolltech.qt.gui.QValidator.QValidationData)"><tt>validate</tt></a> */"/> </class>