Sophie

Sophie

distrib > CentOS > 5 > x86_64 > by-pkgid > ac91357d6caede925de099a02fced14e > files > 4019

qt4-doc-4.2.1-1.el5_7.1.x86_64.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /tmp/qt-4.2.1-harald-1161357942206/qt-x11-opensource-src-4.2.1/src/gui/widgets/qspinbox.cpp -->
<head>
  <title>Qt 4.2: QDoubleSpinBox Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QDoubleSpinBox Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1>
<p>The QDoubleSpinBox class provides a spin box widget that takes doubles. <a href="#details">More...</a></p>
<pre> #include &lt;QDoubleSpinBox&gt;</pre><p>Inherits <a href="qabstractspinbox.html">QAbstractSpinBox</a>.</p>
<ul>
<li><a href="qdoublespinbox-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="properties"></a>
<h3>Properties</h3>
<p><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td width="45%" valign="top"><ul>
<li><div class="fn"/><b><a href="qdoublespinbox.html#cleanText-prop">cleanText</a></b> : const QString</li>
<li><div class="fn"/><b><a href="qdoublespinbox.html#decimals-prop">decimals</a></b> : int</li>
<li><div class="fn"/><b><a href="qdoublespinbox.html#maximum-prop">maximum</a></b> : double</li>
<li><div class="fn"/><b><a href="qdoublespinbox.html#minimum-prop">minimum</a></b> : double</li>
</ul></td><td valign="top"><ul>
<li><div class="fn"/><b><a href="qdoublespinbox.html#prefix-prop">prefix</a></b> : QString</li>
<li><div class="fn"/><b><a href="qdoublespinbox.html#singleStep-prop">singleStep</a></b> : double</li>
<li><div class="fn"/><b><a href="qdoublespinbox.html#suffix-prop">suffix</a></b> : QString</li>
<li><div class="fn"/><b><a href="qdoublespinbox.html#value-prop">value</a></b> : double</li>
</ul>
</td></tr>
</table></p>
<ul>
<li><div class="fn"/>10 properties inherited from <a href="qabstractspinbox.html#properties">QAbstractSpinBox</a></li>
<li><div class="fn"/>55 properties inherited from <a href="qwidget.html#properties">QWidget</a></li>
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="qdoublespinbox.html#QDoubleSpinBox">QDoubleSpinBox</a></b> ( QWidget * <i>parent</i> = 0 )</li>
<li><div class="fn"/>QString <b><a href="qdoublespinbox.html#cleanText-prop">cleanText</a></b> () const</li>
<li><div class="fn"/>int <b><a href="qdoublespinbox.html#decimals-prop">decimals</a></b> () const</li>
<li><div class="fn"/>double <b><a href="qdoublespinbox.html#maximum-prop">maximum</a></b> () const</li>
<li><div class="fn"/>double <b><a href="qdoublespinbox.html#minimum-prop">minimum</a></b> () const</li>
<li><div class="fn"/>QString <b><a href="qdoublespinbox.html#prefix-prop">prefix</a></b> () const</li>
<li><div class="fn"/>void <b><a href="qdoublespinbox.html#decimals-prop">setDecimals</a></b> ( int <i>prec</i> )</li>
<li><div class="fn"/>void <b><a href="qdoublespinbox.html#maximum-prop">setMaximum</a></b> ( double <i>max</i> )</li>
<li><div class="fn"/>void <b><a href="qdoublespinbox.html#minimum-prop">setMinimum</a></b> ( double <i>min</i> )</li>
<li><div class="fn"/>void <b><a href="qdoublespinbox.html#prefix-prop">setPrefix</a></b> ( const QString &amp; <i>prefix</i> )</li>
<li><div class="fn"/>void <b><a href="qdoublespinbox.html#setRange">setRange</a></b> ( double <i>minimum</i>, double <i>maximum</i> )</li>
<li><div class="fn"/>void <b><a href="qdoublespinbox.html#singleStep-prop">setSingleStep</a></b> ( double <i>val</i> )</li>
<li><div class="fn"/>void <b><a href="qdoublespinbox.html#suffix-prop">setSuffix</a></b> ( const QString &amp; <i>suffix</i> )</li>
<li><div class="fn"/>double <b><a href="qdoublespinbox.html#singleStep-prop">singleStep</a></b> () const</li>
<li><div class="fn"/>QString <b><a href="qdoublespinbox.html#suffix-prop">suffix</a></b> () const</li>
<li><div class="fn"/>virtual QString <b><a href="qdoublespinbox.html#textFromValue">textFromValue</a></b> ( double <i>value</i> ) const</li>
<li><div class="fn"/>double <b><a href="qdoublespinbox.html#value-prop">value</a></b> () const</li>
<li><div class="fn"/>virtual double <b><a href="qdoublespinbox.html#valueFromText">valueFromText</a></b> ( const QString &amp; <i>text</i> ) const</li>
</ul>
<ul>
<li><div class="fn"/>22 public functions inherited from <a href="qabstractspinbox.html#public-functions">QAbstractSpinBox</a></li>
<li><div class="fn"/>195 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li>
<li><div class="fn"/>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
<li><div class="fn"/>12 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li>
</ul>
<a name="public-slots"></a>
<h3>Public Slots</h3>
<ul>
<li><div class="fn"/>void <b><a href="qdoublespinbox.html#value-prop">setValue</a></b> ( double <i>val</i> )</li>
</ul>
<ul>
<li><div class="fn"/>4 public slots inherited from <a href="qabstractspinbox.html#public-slots">QAbstractSpinBox</a></li>
<li><div class="fn"/>19 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li>
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
</ul>
<a name="signals"></a>
<h3>Signals</h3>
<ul>
<li><div class="fn"/>void <b><a href="qdoublespinbox.html#valueChanged">valueChanged</a></b> ( double <i>d</i> )</li>
<li><div class="fn"/>void <b><a href="qdoublespinbox.html#valueChanged-2">valueChanged</a></b> ( const QString &amp; <i>text</i> )</li>
</ul>
<ul>
<li><div class="fn"/>1 signal inherited from <a href="qabstractspinbox.html#signals">QAbstractSpinBox</a></li>
<li><div class="fn"/>1 signal inherited from <a href="qwidget.html#signals">QWidget</a></li>
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"/>4 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li>
<li><div class="fn"/>5 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
<li><div class="fn"/>3 protected functions inherited from <a href="qabstractspinbox.html#protected-functions">QAbstractSpinBox</a></li>
<li><div class="fn"/>38 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
<li><div class="fn"/>1 protected function inherited from <a href="qpaintdevice.html#protected-functions">QPaintDevice</a></li>
<li><div class="fn"/>1 protected slot inherited from <a href="qwidget.html#protected-slots">QWidget</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QDoubleSpinBox class provides a spin box widget that takes doubles.</p>
<p>QDoubleSpinBox allows the user to choose a value by clicking the up and down buttons or by pressing Up or Down on the keyboard to increase or decrease the value currently displayed. The user can also type the value in manually. If the value is entered directly into the spin box, the value will be changed and <a href="qdoublespinbox.html#valueChanged">valueChanged</a>() will be emitted with the new value when Enter or Return is pressed, when the spin box loses focus or when the spin box is deactivated (see QWidget::windowActivationChanged()). The spin box supports double values but can be extended to use different strings with <a href="qabstractspinbox.html#validate">validate</a>(), <a href="qdoublespinbox.html#textFromValue">textFromValue</a>() and <a href="qdoublespinbox.html#valueFromText">valueFromText</a>().</p>
<p>Every time the value changes QDoubleSpinBox emits the <a href="qdoublespinbox.html#valueChanged">valueChanged</a>() signal. The current value can be fetched with <a href="qdoublespinbox.html#value-prop">value</a>() and set with <a href="qdoublespinbox.html#value-prop">setValue</a>().</p>
<p>Note: QDoubleSpinBox will round numbers so they can be displayed with the current precision. In a QDoubleSpinBox with decimals set to 2, calling setValue(2.555) will cause <a href="qdoublespinbox.html#value-prop">value</a>() to return 2.56.</p>
<p>Clicking the up and 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="qdoublespinbox.html#singleStep-prop">singleStep</a>(). If you want to change this behavior 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="qdoublespinbox.html#minimum-prop">setMinimum</a>(), <a href="qdoublespinbox.html#maximum-prop">setMaximum</a>() and <a href="qdoublespinbox.html#singleStep-prop">setSingleStep</a>(). The spinbox has a default precision of 2 decimal places but this can be changed using <a href="qdoublespinbox.html#decimals-prop">setDecimals</a>().</p>
<p>Most spin boxes are directional, but QDoubleSpinBox can also operate as a circular spin box, i.e. if the range is 0.0-99.9 and the current value is 99.9, clicking &quot;up&quot; 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="qdoublespinbox.html#prefix-prop">setPrefix</a>() and <a href="qdoublespinbox.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="qdoublespinbox.html#prefix-prop">prefix</a>() and <a href="qdoublespinbox.html#suffix-prop">suffix</a>()), or with <a href="qdoublespinbox.html#cleanText-prop">cleanText</a>() (which has no <a href="qdoublespinbox.html#prefix-prop">prefix</a>(), no <a href="qdoublespinbox.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 QDoubleSpinBox.</p>
<p>See also <a href="qspinbox.html">QSpinBox</a>, <a href="qdatetimeedit.html">QDateTimeEdit</a>, <a href="qslider.html">QSlider</a>, and <a href="widgets-spinboxes.html">Spin Boxes Example</a>.</p>
<hr />
<h2>Property Documentation</h2>
<h3 class="fn"><a name="cleanText-prop"></a>cleanText : const <a href="qstring.html">QString</a></h3>
<p>This property holds the text of the spin box excluding any prefix, suffix, or leading or trailing whitespace.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>QString cleanText () const</b></li>
</ul>
<p>See also <a href="qabstractspinbox.html#text-prop">text</a>, <a href="qdoublespinbox.html#prefix-prop">QDoubleSpinBox::prefix</a>, and <a href="qdoublespinbox.html#suffix-prop">QDoubleSpinBox::suffix</a>.</p>
<h3 class="fn"><a name="decimals-prop"></a>decimals : int</h3>
<p>This property holds the precision of the spin box, in decimals.</p>
<p>Sets how many decimals the spinbox will use for displaying and interpreting doubles. The valid decimal range is 0-13. The default is 2. <i>decimals</i> will be bounded to a value that is within the valid range.</p>
<p>Note: The maximum, minimum and value might change as a result of changing this property.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>int decimals () const</b></li>
<li><div class="fn"/><b>void setDecimals ( int <i>prec</i> )</b></li>
</ul>
<h3 class="fn"><a name="maximum-prop"></a>maximum : double</h3>
<p>This property holds the maximum value of the spin box.</p>
<p>When setting this property the <a href="qdoublespinbox.html#minimum-prop">minimum</a> is adjusted if necessary, to ensure that the range remains valid.</p>
<p>The default maximum value is 99.99.</p>
<p>Note: The maximum value will be rounded to match the decimals property.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>double maximum () const</b></li>
<li><div class="fn"/><b>void setMaximum ( double <i>max</i> )</b></li>
</ul>
<p>See also <a href="qdoublespinbox.html#decimals-prop">decimals</a> and <a href="qdoublespinbox.html#setRange">setRange</a>().</p>
<h3 class="fn"><a name="minimum-prop"></a>minimum : double</h3>
<p>This property holds the minimum value of the spin box.</p>
<p>When setting this property the <a href="qdoublespinbox.html#maximum-prop">maximum</a> is adjusted if necessary to ensure that the range remains valid.</p>
<p>The default minimum value is 0.0.</p>
<p>Note: The minimum value will be rounded to match the decimals property.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>double minimum () const</b></li>
<li><div class="fn"/><b>void setMinimum ( double <i>min</i> )</b></li>
</ul>
<p>See also <a href="qdoublespinbox.html#decimals-prop">decimals</a>, <a href="qdoublespinbox.html#setRange">setRange</a>(), and <a href="qabstractspinbox.html#specialValueText-prop">specialValueText</a>.</p>
<h3 class="fn"><a name="prefix-prop"></a>prefix : <a href="qstring.html">QString</a></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> spinbox-&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="qdoublespinbox.html#value-prop">value</a>() == <a href="qdoublespinbox.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>Access functions:</p>
<ul>
<li><div class="fn"/><b>QString prefix () const</b></li>
<li><div class="fn"/><b>void setPrefix ( const QString &amp; <i>prefix</i> )</b></li>
</ul>
<p>See also <a href="qdoublespinbox.html#suffix-prop">suffix</a>(), <a href="qdoublespinbox.html#suffix-prop">setSuffix</a>(), <a href="qabstractspinbox.html#specialValueText-prop">specialValueText</a>(), and <a href="qabstractspinbox.html#specialValueText-prop">setSpecialValueText</a>().</p>
<h3 class="fn"><a name="singleStep-prop"></a>singleStep : double</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.0. Setting a singleStep value of less than 0 does nothing.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>double singleStep () const</b></li>
<li><div class="fn"/><b>void setSingleStep ( double <i>val</i> )</b></li>
</ul>
<h3 class="fn"><a name="suffix-prop"></a>suffix : <a href="qstring.html">QString</a></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> spinbox-&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="qdoublespinbox.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>Access functions:</p>
<ul>
<li><div class="fn"/><b>QString suffix () const</b></li>
<li><div class="fn"/><b>void setSuffix ( const QString &amp; <i>suffix</i> )</b></li>
</ul>
<p>See also <a href="qdoublespinbox.html#prefix-prop">prefix</a>(), <a href="qdoublespinbox.html#prefix-prop">setPrefix</a>(), <a href="qabstractspinbox.html#specialValueText-prop">specialValueText</a>(), and <a href="qabstractspinbox.html#specialValueText-prop">setSpecialValueText</a>().</p>
<h3 class="fn"><a name="value-prop"></a>value : double</h3>
<p>This property holds the value of the spin box.</p>
<p>setValue() will emit <a href="qdoublespinbox.html#valueChanged">valueChanged</a>() if the new value is different from the old one.</p>
<p>Note: The value will be rounded so it can be displayed with the current setting of decimals.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>double value () const</b></li>
<li><div class="fn"/><b>void setValue ( double <i>val</i> )</b></li>
</ul>
<p>See also <a href="qdoublespinbox.html#decimals-prop">decimals</a>.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QDoubleSpinBox"></a>QDoubleSpinBox::QDoubleSpinBox ( <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0 )</h3>
<p>Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value, a step value of 1.0 and a precision of 2 decimal places. The value is initially set to 0.00. The spin box has the given <i>parent</i>.</p>
<p>See also <a href="qdoublespinbox.html#minimum-prop">setMinimum</a>(), <a href="qdoublespinbox.html#maximum-prop">setMaximum</a>(), and <a href="qdoublespinbox.html#singleStep-prop">setSingleStep</a>().</p>
<h3 class="fn"><a name="setRange"></a>void QDoubleSpinBox::setRange ( double <i>minimum</i>, double <i>maximum</i> )</h3>
<p>Convenience function to set the <i>minimum</i> and <i>maximum</i> values with a single function call.</p>
<p>Note: The maximum and minimum values will be rounded to match the decimals property.</p>
<pre> setRange(minimum, maximum);</pre>
<p>is equivalent to:</p>
<pre> setMinimum(minimum);
 setMaximum(maximum);</pre>
<p>See also <a href="qdoublespinbox.html#minimum-prop">minimum</a> and <a href="qdoublespinbox.html#maximum-prop">maximum</a>.</p>
<h3 class="fn"><a name="textFromValue"></a><a href="qstring.html">QString</a> QDoubleSpinBox::textFromValue ( double <i>value</i> ) const&nbsp;&nbsp;<tt> [virtual]</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 using QLocale().toString(<i>value</i>, <a href="qlatin1char.html">QLatin1Char</a>('f'), <a href="qdoublespinbox.html#decimals-prop">decimals</a>()) and will remove the thousand seperator. Reimplementations may return anything.</p>
<p>Note: <a href="qdoublespinbox.html">QDoubleSpinBox</a> does not call this function for <a href="qabstractspinbox.html#specialValueText-prop">specialValueText</a>() and that neither <a href="qdoublespinbox.html#prefix-prop">prefix</a>() nor <a href="qdoublespinbox.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="qdoublespinbox.html#valueFromText">valueFromText</a>().</p>
<p>See also <a href="qdoublespinbox.html#valueFromText">valueFromText</a>().</p>
<h3 class="fn"><a name="valueChanged"></a>void QDoubleSpinBox::valueChanged ( double <i>d</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted whenever the spin box's value is changed. The new value is passed in <i>d</i>.</p>
<h3 class="fn"><a name="valueChanged-2"></a>void QDoubleSpinBox::valueChanged ( const <a href="qstring.html">QString</a> &amp; <i>text</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>The new value is passed literally in <i>text</i> with no <a href="qdoublespinbox.html#prefix-prop">prefix</a>() or <a href="qdoublespinbox.html#suffix-prop">suffix</a>().</p>
<h3 class="fn"><a name="valueFromText"></a>double QDoubleSpinBox::valueFromText ( const <a href="qstring.html">QString</a> &amp; <i>text</i> ) const&nbsp;&nbsp;<tt> [virtual]</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="qdoublespinbox.html">QDoubleSpinBox</a> handles <a href="qabstractspinbox.html#specialValueText-prop">specialValueText</a>() separately; this function is only concerned with the other values.</p>
<p>See also <a href="qdoublespinbox.html#textFromValue">textFromValue</a>() and <a href="qabstractspinbox.html#validate">validate</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2006 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.2.1</div></td>
</tr></table></div></address></body>
</html>