1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qspinbox.cpp:129 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>QSpinBox Class</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QSpinBox Class Reference</h1>
|
---|
33 |
|
---|
34 | <p>The QSpinBox class provides a spin box widget (spin button).
|
---|
35 | <a href="#details">More...</a>
|
---|
36 | <p><tt>#include <<a href="qspinbox-h.html">qspinbox.h</a>></tt>
|
---|
37 | <p>Inherits <a href="qwidget.html">QWidget</a> and <a href="qrangecontrol.html">QRangeControl</a>.
|
---|
38 | <p><a href="qspinbox-members.html">List of all member functions.</a>
|
---|
39 | <h2>Public Members</h2>
|
---|
40 | <ul>
|
---|
41 | <li class=fn><a href="#QSpinBox"><b>QSpinBox</b></a> ( QWidget * parent = 0, const char * name = 0 )</li>
|
---|
42 | <li class=fn><a href="#QSpinBox-2"><b>QSpinBox</b></a> ( int minValue, int maxValue, int step = 1, QWidget * parent = 0, const char * name = 0 )</li>
|
---|
43 | <li class=fn><a href="#~QSpinBox"><b>~QSpinBox</b></a> ()</li>
|
---|
44 | <li class=fn>QString <a href="#text"><b>text</b></a> () const</li>
|
---|
45 | <li class=fn>virtual QString <a href="#prefix"><b>prefix</b></a> () const</li>
|
---|
46 | <li class=fn>virtual QString <a href="#suffix"><b>suffix</b></a> () const</li>
|
---|
47 | <li class=fn>virtual QString <a href="#cleanText"><b>cleanText</b></a> () const</li>
|
---|
48 | <li class=fn>virtual void <a href="#setSpecialValueText"><b>setSpecialValueText</b></a> ( const QString & text )</li>
|
---|
49 | <li class=fn>QString <a href="#specialValueText"><b>specialValueText</b></a> () const</li>
|
---|
50 | <li class=fn>virtual void <a href="#setWrapping"><b>setWrapping</b></a> ( bool on )</li>
|
---|
51 | <li class=fn>bool <a href="#wrapping"><b>wrapping</b></a> () const</li>
|
---|
52 | <li class=fn>enum <a href="#ButtonSymbols-enum"><b>ButtonSymbols</b></a> { UpDownArrows, PlusMinus }</li>
|
---|
53 | <li class=fn>virtual void <a href="#setButtonSymbols"><b>setButtonSymbols</b></a> ( ButtonSymbols )</li>
|
---|
54 | <li class=fn>ButtonSymbols <a href="#buttonSymbols"><b>buttonSymbols</b></a> () const</li>
|
---|
55 | <li class=fn>virtual void <a href="#setValidator"><b>setValidator</b></a> ( const QValidator * v )</li>
|
---|
56 | <li class=fn>const QValidator * <a href="#validator"><b>validator</b></a> () const</li>
|
---|
57 | <li class=fn>int <a href="#minValue"><b>minValue</b></a> () const</li>
|
---|
58 | <li class=fn>int <a href="#maxValue"><b>maxValue</b></a> () const</li>
|
---|
59 | <li class=fn>void <a href="#setMinValue"><b>setMinValue</b></a> ( int )</li>
|
---|
60 | <li class=fn>void <a href="#setMaxValue"><b>setMaxValue</b></a> ( int )</li>
|
---|
61 | <li class=fn>int <a href="#lineStep"><b>lineStep</b></a> () const</li>
|
---|
62 | <li class=fn>void <a href="#setLineStep"><b>setLineStep</b></a> ( int )</li>
|
---|
63 | <li class=fn>int <a href="#value"><b>value</b></a> () const</li>
|
---|
64 | <li class=fn>QRect <a href="#upRect"><b>upRect</b></a> () const</li>
|
---|
65 | <li class=fn>QRect <a href="#downRect"><b>downRect</b></a> () const</li>
|
---|
66 | </ul>
|
---|
67 | <h2>Public Slots</h2>
|
---|
68 | <ul>
|
---|
69 | <li class=fn>virtual void <a href="#setValue"><b>setValue</b></a> ( int value )</li>
|
---|
70 | <li class=fn>virtual void <a href="#setPrefix"><b>setPrefix</b></a> ( const QString & text )</li>
|
---|
71 | <li class=fn>virtual void <a href="#setSuffix"><b>setSuffix</b></a> ( const QString & text )</li>
|
---|
72 | <li class=fn>virtual void <a href="#stepUp"><b>stepUp</b></a> ()</li>
|
---|
73 | <li class=fn>virtual void <a href="#stepDown"><b>stepDown</b></a> ()</li>
|
---|
74 | <li class=fn>virtual void <a href="#selectAll"><b>selectAll</b></a> ()</li>
|
---|
75 | </ul>
|
---|
76 | <h2>Signals</h2>
|
---|
77 | <ul>
|
---|
78 | <li class=fn>void <a href="#valueChanged"><b>valueChanged</b></a> ( int value )</li>
|
---|
79 | <li class=fn>void <a href="#valueChanged-2"><b>valueChanged</b></a> ( const QString & valueText )</li>
|
---|
80 | </ul>
|
---|
81 | <h2>Properties</h2>
|
---|
82 | <ul>
|
---|
83 | <li class=fn>ButtonSymbols <a href="#buttonSymbols-prop"><b>buttonSymbols</b></a> - the current button symbol mode</li>
|
---|
84 | <li class=fn>QString <a href="#cleanText-prop"><b>cleanText</b></a> - the spin box's text with no prefix(), suffix() or leading or trailing whitespace <em>(read only)</em></li>
|
---|
85 | <li class=fn>int <a href="#lineStep-prop"><b>lineStep</b></a> - the line step</li>
|
---|
86 | <li class=fn>int <a href="#maxValue-prop"><b>maxValue</b></a> - the maximum value of the spin box</li>
|
---|
87 | <li class=fn>int <a href="#minValue-prop"><b>minValue</b></a> - the minimum value of the spin box</li>
|
---|
88 | <li class=fn>QString <a href="#prefix-prop"><b>prefix</b></a> - the spin box's prefix</li>
|
---|
89 | <li class=fn>QString <a href="#specialValueText-prop"><b>specialValueText</b></a> - the special-value text</li>
|
---|
90 | <li class=fn>QString <a href="#suffix-prop"><b>suffix</b></a> - the suffix of the spin box</li>
|
---|
91 | <li class=fn>QString <a href="#text-prop"><b>text</b></a> - the spin box's text, including any prefix() and suffix() <em>(read only)</em></li>
|
---|
92 | <li class=fn>int <a href="#value-prop"><b>value</b></a> - the value of the spin box</li>
|
---|
93 | <li class=fn>bool <a href="#wrapping-prop"><b>wrapping</b></a> - whether it is possible to step the value from the highest value to the lowest value and vice versa</li>
|
---|
94 | </ul>
|
---|
95 | <h2>Protected Members</h2>
|
---|
96 | <ul>
|
---|
97 | <li class=fn>virtual QString <a href="#mapValueToText"><b>mapValueToText</b></a> ( int v )</li>
|
---|
98 | <li class=fn>virtual int <a href="#mapTextToValue"><b>mapTextToValue</b></a> ( bool * ok )</li>
|
---|
99 | <li class=fn>QString <a href="#currentValueText"><b>currentValueText</b></a> ()</li>
|
---|
100 | <li class=fn>virtual void <a href="#updateDisplay"><b>updateDisplay</b></a> ()</li>
|
---|
101 | <li class=fn>virtual void <a href="#interpretText"><b>interpretText</b></a> ()</li>
|
---|
102 | <li class=fn>QLineEdit * <a href="#editor"><b>editor</b></a> () const</li>
|
---|
103 | <li class=fn>virtual void <a href="#valueChange"><b>valueChange</b></a> ()</li>
|
---|
104 | <li class=fn>virtual void <a href="#rangeChange"><b>rangeChange</b></a> ()</li>
|
---|
105 | <li class=fn>virtual bool <a href="#eventFilter"><b>eventFilter</b></a> ( QObject * o, QEvent * ev )</li>
|
---|
106 | </ul>
|
---|
107 | <h2>Protected Slots</h2>
|
---|
108 | <ul>
|
---|
109 | <li class=fn>void <a href="#textChanged"><b>textChanged</b></a> ()</li>
|
---|
110 | </ul>
|
---|
111 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
112 |
|
---|
113 |
|
---|
114 | The QSpinBox class provides a spin box widget (spin button).
|
---|
115 | <p>
|
---|
116 |
|
---|
117 | <p> QSpinBox allows the user to choose a value either by clicking the
|
---|
118 | up/down buttons to increase/decrease the value currently displayed
|
---|
119 | or by typing the value directly into the spin box. If the value is
|
---|
120 | entered directly into the spin box, Enter (or Return) must be
|
---|
121 | pressed to apply the new value. The value is usually an integer.
|
---|
122 | <p> Every time the value changes QSpinBox emits the <a href="#valueChanged">valueChanged</a>()
|
---|
123 | signal. The current value can be fetched with <a href="#value">value</a>() and set
|
---|
124 | with <a href="#setValue">setValue</a>().
|
---|
125 | <p> The spin box keeps the value within a numeric range, and to
|
---|
126 | multiples of the <a href="#lineStep">lineStep</a>() size (see <a href="qrangecontrol.html">QRangeControl</a> for details).
|
---|
127 | Clicking the up/down buttons or using the keyboard accelerator's
|
---|
128 | up and down arrows will increase or decrease the current value in
|
---|
129 | steps of size lineStep(). The minimum and maximum value and the
|
---|
130 | step size can be set using one of the constructors, and can be
|
---|
131 | changed later with <a href="#setMinValue">setMinValue</a>(), <a href="#setMaxValue">setMaxValue</a>() and <a href="#setLineStep">setLineStep</a>().
|
---|
132 | <p> Most spin boxes are directional, but QSpinBox can also operate as
|
---|
133 | a circular spin box, i.e. if the range is 0-99 and the current
|
---|
134 | value is 99, clicking "up" will give 0. Use <a href="#setWrapping">setWrapping</a>() if you
|
---|
135 | want circular behavior.
|
---|
136 | <p> The displayed value can be prepended and appended with arbitrary
|
---|
137 | strings indicating, for example, currency or the unit of
|
---|
138 | measurement. See <a href="#setPrefix">setPrefix</a>() and <a href="#setSuffix">setSuffix</a>(). The text in the spin
|
---|
139 | box is retrieved with <a href="#text">text</a>() (which includes any <a href="#prefix">prefix</a>() and
|
---|
140 | <a href="#suffix">suffix</a>()), or with <a href="#cleanText">cleanText</a>() (which has no prefix(), no suffix()
|
---|
141 | and no leading or trailing whitespace). <a href="#currentValueText">currentValueText</a>() returns
|
---|
142 | the spin box's current value as text.
|
---|
143 | <p> Normally the spin box displays up and down arrows in the buttons.
|
---|
144 | You can use <a href="#setButtonSymbols">setButtonSymbols</a>() to change the display to show
|
---|
145 | <b>+</b> and <b>-</b> symbols if you prefer. In either case the up
|
---|
146 | and down arrow keys work as expected.
|
---|
147 | <p> It is often desirable to give the user a special (often default)
|
---|
148 | choice in addition to the range of numeric values. See
|
---|
149 | <a href="#setSpecialValueText">setSpecialValueText</a>() for how to do this with QSpinBox.
|
---|
150 | <p> The default <a href="qwidget.html#focusPolicy">QWidget::focusPolicy</a>() is StrongFocus.
|
---|
151 | <p> If using prefix(), suffix() and <a href="#specialValueText">specialValueText</a>() don't provide
|
---|
152 | enough control, you can ignore them and subclass QSpinBox instead.
|
---|
153 | <p> QSpinBox can easily be subclassed to allow the user to input
|
---|
154 | things other than an integer value as long as the allowed input
|
---|
155 | can be mapped to a range of integers. This can be done by
|
---|
156 | overriding the virtual functions <a href="#mapValueToText">mapValueToText</a>() and
|
---|
157 | <a href="#mapTextToValue">mapTextToValue</a>(), and setting another suitable validator using
|
---|
158 | <a href="#setValidator">setValidator</a>().
|
---|
159 | <p> For example, these functions could be changed so that the user
|
---|
160 | provided values from 0.0 to 10.0, or -1 to signify 'Auto', while
|
---|
161 | the range of integers used inside the program would be -1 to 100:
|
---|
162 | <p> <pre>
|
---|
163 | class MySpinBox : public QSpinBox
|
---|
164 | {
|
---|
165 | Q_OBJECT
|
---|
166 | public:
|
---|
167 | ...
|
---|
168 |
|
---|
169 | <a href="qstring.html">QString</a> mapValueToText( int value )
|
---|
170 | {
|
---|
171 | if ( <a href="#value-prop">value</a> == -1 ) // special case
|
---|
172 | return QString( "Auto" );
|
---|
173 |
|
---|
174 | return QString( "%1.%2" ) // 0.0 to 10.0
|
---|
175 | .arg( value / 10 ).arg( value % 10 );
|
---|
176 | }
|
---|
177 |
|
---|
178 | int mapTextToValue( bool *ok )
|
---|
179 | {
|
---|
180 | if ( <a href="#text">text</a>() == "Auto" ) // special case
|
---|
181 | return -1;
|
---|
182 |
|
---|
183 | return (int) ( 10 * text().toFloat() ); // 0 to 100
|
---|
184 | }
|
---|
185 | };
|
---|
186 | </pre>
|
---|
187 |
|
---|
188 | <p> <img src=qspinbox-m.png> <img src=qspinbox-w.png>
|
---|
189 | <p> <p>See also <a href="qscrollbar.html">QScrollBar</a>, <a href="qslider.html">QSlider</a>, <a href="guibooks.html#fowler">GUI Design Handbook: Spin Box</a>, and <a href="basic.html">Basic Widgets</a>.
|
---|
190 |
|
---|
191 | <hr><h2>Member Type Documentation</h2>
|
---|
192 | <h3 class=fn><a name="ButtonSymbols-enum"></a>QSpinBox::ButtonSymbols</h3>
|
---|
193 |
|
---|
194 | <p> This enum type determines what the buttons in a spin box show.
|
---|
195 | <ul>
|
---|
196 | <li><tt>QSpinBox::UpDownArrows</tt> - the buttons show little arrows in the classic
|
---|
197 | style.
|
---|
198 | <li><tt>QSpinBox::PlusMinus</tt> - the buttons show <b>+</b> and <b>-</b> symbols.
|
---|
199 | </ul><p> <p>See also <a href="#buttonSymbols-prop">QSpinBox::buttonSymbols</a>.
|
---|
200 |
|
---|
201 | <hr><h2>Member Function Documentation</h2>
|
---|
202 | <h3 class=fn><a name="QSpinBox"></a>QSpinBox::QSpinBox ( <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0 )
|
---|
203 | </h3>
|
---|
204 | Constructs a spin box with the default <a href="qrangecontrol.html">QRangeControl</a> range and
|
---|
205 | step values. It is called <em>name</em> and has parent <em>parent</em>.
|
---|
206 | <p> <p>See also <a href="#minValue-prop">minValue</a>, <a href="#maxValue-prop">maxValue</a>, <a href="qrangecontrol.html#setRange">setRange</a>(), <a href="#lineStep-prop">lineStep</a>, and <a href="qrangecontrol.html#setSteps">setSteps</a>().
|
---|
207 |
|
---|
208 | <h3 class=fn><a name="QSpinBox-2"></a>QSpinBox::QSpinBox ( int minValue, int maxValue, int step = 1, <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0 )
|
---|
209 | </h3>
|
---|
210 | Constructs a spin box that allows values from <em>minValue</em> to <em>maxValue</em> inclusive, with step amount <em>step</em>. The value is
|
---|
211 | initially set to <em>minValue</em>.
|
---|
212 | <p> The spin box is called <em>name</em> and has parent <em>parent</em>.
|
---|
213 | <p> <p>See also <a href="#minValue-prop">minValue</a>, <a href="#maxValue-prop">maxValue</a>, <a href="qrangecontrol.html#setRange">setRange</a>(), <a href="#lineStep-prop">lineStep</a>, and <a href="qrangecontrol.html#setSteps">setSteps</a>().
|
---|
214 |
|
---|
215 | <h3 class=fn><a name="~QSpinBox"></a>QSpinBox::~QSpinBox ()
|
---|
216 | </h3>
|
---|
217 | Destroys the spin box, freeing all memory and other resources.
|
---|
218 |
|
---|
219 | <h3 class=fn><a href="qspinbox.html#ButtonSymbols-enum">ButtonSymbols</a> <a name="buttonSymbols"></a>QSpinBox::buttonSymbols () const
|
---|
220 | </h3><p>Returns the current button symbol mode.
|
---|
221 | See the <a href="qspinbox.html#buttonSymbols-prop">"buttonSymbols"</a> property for details.
|
---|
222 | <h3 class=fn><a href="qstring.html">QString</a> <a name="cleanText"></a>QSpinBox::cleanText () const<tt> [virtual]</tt>
|
---|
223 | </h3><p>Returns the spin box's text with no <a href="#prefix">prefix</a>(), <a href="#suffix">suffix</a>() or leading or trailing whitespace.
|
---|
224 | See the <a href="qspinbox.html#cleanText-prop">"cleanText"</a> property for details.
|
---|
225 | <h3 class=fn><a href="qstring.html">QString</a> <a name="currentValueText"></a>QSpinBox::currentValueText ()<tt> [protected]</tt>
|
---|
226 | </h3>
|
---|
227 | Returns the full text calculated from the current value, including
|
---|
228 | any prefix and suffix. If there is special value text and the
|
---|
229 | value is <a href="#minValue">minValue</a>() the <a href="#specialValueText">specialValueText</a>() is returned.
|
---|
230 |
|
---|
231 | <h3 class=fn><a href="qrect.html">QRect</a> <a name="downRect"></a>QSpinBox::downRect () const
|
---|
232 | </h3>
|
---|
233 | Returns the geometry of the "down" button.
|
---|
234 |
|
---|
235 | <h3 class=fn><a href="qlineedit.html">QLineEdit</a> * <a name="editor"></a>QSpinBox::editor () const<tt> [protected]</tt>
|
---|
236 | </h3>
|
---|
237 | Returns a pointer to the embedded <a href="qlineedit.html">QLineEdit</a>.
|
---|
238 |
|
---|
239 | <h3 class=fn>bool <a name="eventFilter"></a>QSpinBox::eventFilter ( <a href="qobject.html">QObject</a> * o, <a href="qevent.html">QEvent</a> * ev )<tt> [virtual protected]</tt>
|
---|
240 | </h3>
|
---|
241 | Intercepts and handles the events coming to the embedded <a href="qlineedit.html">QLineEdit</a>
|
---|
242 | that have special meaning for the QSpinBox. The object is passed
|
---|
243 | as <em>o</em> and the event is passed as <em>ev</em>.
|
---|
244 |
|
---|
245 | <p>Reimplemented from <a href="qobject.html#eventFilter">QObject</a>.
|
---|
246 | <h3 class=fn>void <a name="interpretText"></a>QSpinBox::interpretText ()<tt> [virtual protected]</tt>
|
---|
247 | </h3>
|
---|
248 | QSpinBox calls this after the user has manually edited the
|
---|
249 | contents of the spin box (i.e. by typing in the embedded
|
---|
250 | <a href="qlineedit.html">QLineEdit</a>, rather than using the up/down buttons/keys).
|
---|
251 | <p> The default implementation of this function interprets the new
|
---|
252 | text using <a href="#mapTextToValue">mapTextToValue</a>(). If mapTextToValue() is successful, it
|
---|
253 | changes the spin box's value; if not, the value is left unchanged.
|
---|
254 | <p> <p>See also <a href="#editor">editor</a>().
|
---|
255 |
|
---|
256 | <h3 class=fn>int <a name="lineStep"></a>QSpinBox::lineStep () const
|
---|
257 | </h3><p>Returns the line step.
|
---|
258 | See the <a href="qspinbox.html#lineStep-prop">"lineStep"</a> property for details.
|
---|
259 | <h3 class=fn>int <a name="mapTextToValue"></a>QSpinBox::mapTextToValue ( bool * ok )<tt> [virtual protected]</tt>
|
---|
260 | </h3>
|
---|
261 | This virtual function is used by the spin box whenever it needs to
|
---|
262 | interpret text entered by the user as a value. The text is
|
---|
263 | available as <a href="#text">text</a>() and as <a href="#cleanText">cleanText</a>(), and this function must
|
---|
264 | parse it if possible. If <em>ok</em> is not 0: if it parses the text
|
---|
265 | successfully, <em>*ok</em> is set to TRUE; otherwise <em>*ok</em> is set to
|
---|
266 | FALSE.
|
---|
267 | <p> Subclasses that need to display spin box values in a non-numeric
|
---|
268 | way need to reimplement this function.
|
---|
269 | <p> Note that Qt handles <a href="#specialValueText">specialValueText</a>() separately; this function
|
---|
270 | is only concerned with the other values.
|
---|
271 | <p> The default implementation tries to interpret the text() as an
|
---|
272 | integer in the standard way and returns the integer value.
|
---|
273 | <p> <p>See also <a href="#interpretText">interpretText</a>() and <a href="#mapValueToText">mapValueToText</a>().
|
---|
274 |
|
---|
275 | <h3 class=fn><a href="qstring.html">QString</a> <a name="mapValueToText"></a>QSpinBox::mapValueToText ( int v )<tt> [virtual protected]</tt>
|
---|
276 | </h3>
|
---|
277 | This virtual function is used by the spin box whenever it needs to
|
---|
278 | display value <em>v</em>. The default implementation returns a string
|
---|
279 | containing <em>v</em> printed in the standard way. Reimplementations may
|
---|
280 | return anything. (See the example in the detailed description.)
|
---|
281 | <p> Note that Qt does not call this function for <a href="#specialValueText">specialValueText</a>()
|
---|
282 | and that neither <a href="#prefix">prefix</a>() nor <a href="#suffix">suffix</a>() are included in the return
|
---|
283 | value.
|
---|
284 | <p> If you reimplement this, you may also need to reimplement
|
---|
285 | <a href="#mapTextToValue">mapTextToValue</a>().
|
---|
286 | <p> <p>See also <a href="#updateDisplay">updateDisplay</a>() and <a href="#mapTextToValue">mapTextToValue</a>().
|
---|
287 |
|
---|
288 | <h3 class=fn>int <a name="maxValue"></a>QSpinBox::maxValue () const
|
---|
289 | </h3><p>Returns the maximum value of the spin box.
|
---|
290 | See the <a href="qspinbox.html#maxValue-prop">"maxValue"</a> property for details.
|
---|
291 | <h3 class=fn>int <a name="minValue"></a>QSpinBox::minValue () const
|
---|
292 | </h3><p>Returns the minimum value of the spin box.
|
---|
293 | See the <a href="qspinbox.html#minValue-prop">"minValue"</a> property for details.
|
---|
294 | <h3 class=fn><a href="qstring.html">QString</a> <a name="prefix"></a>QSpinBox::prefix () const<tt> [virtual]</tt>
|
---|
295 | </h3><p>Returns the spin box's prefix.
|
---|
296 | See the <a href="qspinbox.html#prefix-prop">"prefix"</a> property for details.
|
---|
297 | <h3 class=fn>void <a name="rangeChange"></a>QSpinBox::rangeChange ()<tt> [virtual protected]</tt>
|
---|
298 | </h3>
|
---|
299 | This virtual function is called by <a href="qrangecontrol.html">QRangeControl</a> whenever the
|
---|
300 | range has changed. It adjusts the default validator and updates
|
---|
301 | the display; if you need additional processing, you can
|
---|
302 | reimplement this function.
|
---|
303 |
|
---|
304 | <p>Reimplemented from <a href="qrangecontrol.html#rangeChange">QRangeControl</a>.
|
---|
305 | <h3 class=fn>void <a name="selectAll"></a>QSpinBox::selectAll ()<tt> [virtual slot]</tt>
|
---|
306 | </h3>
|
---|
307 | Selects all the text in the spin box's editor.
|
---|
308 |
|
---|
309 | <h3 class=fn>void <a name="setButtonSymbols"></a>QSpinBox::setButtonSymbols ( <a href="qspinbox.html#ButtonSymbols-enum">ButtonSymbols</a> )<tt> [virtual]</tt>
|
---|
310 | </h3><p>Sets the current button symbol mode.
|
---|
311 | See the <a href="qspinbox.html#buttonSymbols-prop">"buttonSymbols"</a> property for details.
|
---|
312 | <h3 class=fn>void <a name="setLineStep"></a>QSpinBox::setLineStep ( int )
|
---|
313 | </h3><p>Sets the line step.
|
---|
314 | See the <a href="qspinbox.html#lineStep-prop">"lineStep"</a> property for details.
|
---|
315 | <h3 class=fn>void <a name="setMaxValue"></a>QSpinBox::setMaxValue ( int )
|
---|
316 | </h3><p>Sets the maximum value of the spin box.
|
---|
317 | See the <a href="qspinbox.html#maxValue-prop">"maxValue"</a> property for details.
|
---|
318 | <h3 class=fn>void <a name="setMinValue"></a>QSpinBox::setMinValue ( int )
|
---|
319 | </h3><p>Sets the minimum value of the spin box.
|
---|
320 | See the <a href="qspinbox.html#minValue-prop">"minValue"</a> property for details.
|
---|
321 | <h3 class=fn>void <a name="setPrefix"></a>QSpinBox::setPrefix ( const <a href="qstring.html">QString</a> & text )<tt> [virtual slot]</tt>
|
---|
322 | </h3><p>Sets the spin box's prefix to <em>text</em>.
|
---|
323 | See the <a href="qspinbox.html#prefix-prop">"prefix"</a> property for details.
|
---|
324 | <h3 class=fn>void <a name="setSpecialValueText"></a>QSpinBox::setSpecialValueText ( const <a href="qstring.html">QString</a> & text )<tt> [virtual]</tt>
|
---|
325 | </h3><p>Sets the special-value text to <em>text</em>.
|
---|
326 | See the <a href="qspinbox.html#specialValueText-prop">"specialValueText"</a> property for details.
|
---|
327 | <h3 class=fn>void <a name="setSuffix"></a>QSpinBox::setSuffix ( const <a href="qstring.html">QString</a> & text )<tt> [virtual slot]</tt>
|
---|
328 | </h3><p>Sets the suffix of the spin box to <em>text</em>.
|
---|
329 | See the <a href="qspinbox.html#suffix-prop">"suffix"</a> property for details.
|
---|
330 | <h3 class=fn>void <a name="setValidator"></a>QSpinBox::setValidator ( const <a href="qvalidator.html">QValidator</a> * v )<tt> [virtual]</tt>
|
---|
331 | </h3>
|
---|
332 | Sets the validator to <em>v</em>. The validator controls what keyboard
|
---|
333 | input is accepted when the user is editing in the value field. The
|
---|
334 | default is to use a suitable <a href="qintvalidator.html">QIntValidator</a>.
|
---|
335 | <p> Use <a href="#setValidator">setValidator</a>(0) to turn off input validation (entered input
|
---|
336 | will still be kept within the spin box's range).
|
---|
337 |
|
---|
338 | <h3 class=fn>void <a name="setValue"></a>QSpinBox::setValue ( int value )<tt> [virtual slot]</tt>
|
---|
339 | </h3><p>Sets the value of the spin box to <em>value</em>.
|
---|
340 | See the <a href="qspinbox.html#value-prop">"value"</a> property for details.
|
---|
341 | <h3 class=fn>void <a name="setWrapping"></a>QSpinBox::setWrapping ( bool on )<tt> [virtual]</tt>
|
---|
342 | </h3><p>Sets whether it is possible to step the value from the highest value to the lowest value and vice versa to <em>on</em>.
|
---|
343 | See the <a href="qspinbox.html#wrapping-prop">"wrapping"</a> property for details.
|
---|
344 | <h3 class=fn><a href="qstring.html">QString</a> <a name="specialValueText"></a>QSpinBox::specialValueText () const
|
---|
345 | </h3><p>Returns the special-value text.
|
---|
346 | See the <a href="qspinbox.html#specialValueText-prop">"specialValueText"</a> property for details.
|
---|
347 | <h3 class=fn>void <a name="stepDown"></a>QSpinBox::stepDown ()<tt> [virtual slot]</tt>
|
---|
348 | </h3>
|
---|
349 | Decreases the spin box's value one <a href="#lineStep">lineStep</a>(), wrapping as
|
---|
350 | necessary if <a href="#wrapping">wrapping</a>() is TRUE. This is the same as clicking on
|
---|
351 | the pointing-down button and can be used for keyboard
|
---|
352 | accelerators, for example.
|
---|
353 | <p> <p>See also <a href="#stepUp">stepUp</a>(), <a href="qrangecontrol.html#subtractLine">subtractLine</a>(), <a href="#lineStep-prop">lineStep</a>, <a href="qrangecontrol.html#setSteps">setSteps</a>(), <a href="#value-prop">value</a>, and <a href="#value-prop">value</a>.
|
---|
354 |
|
---|
355 | <h3 class=fn>void <a name="stepUp"></a>QSpinBox::stepUp ()<tt> [virtual slot]</tt>
|
---|
356 | </h3>
|
---|
357 | Increases the spin box's value by one <a href="#lineStep">lineStep</a>(), wrapping as
|
---|
358 | necessary if <a href="#wrapping">wrapping</a>() is TRUE. This is the same as clicking on
|
---|
359 | the pointing-up button and can be used for keyboard accelerators,
|
---|
360 | for example.
|
---|
361 | <p> <p>See also <a href="#stepDown">stepDown</a>(), <a href="qrangecontrol.html#addLine">addLine</a>(), <a href="#lineStep-prop">lineStep</a>, <a href="qrangecontrol.html#setSteps">setSteps</a>(), <a href="#value-prop">value</a>, and <a href="#value-prop">value</a>.
|
---|
362 |
|
---|
363 | <h3 class=fn><a href="qstring.html">QString</a> <a name="suffix"></a>QSpinBox::suffix () const<tt> [virtual]</tt>
|
---|
364 | </h3><p>Returns the suffix of the spin box.
|
---|
365 | See the <a href="qspinbox.html#suffix-prop">"suffix"</a> property for details.
|
---|
366 | <h3 class=fn><a href="qstring.html">QString</a> <a name="text"></a>QSpinBox::text () const
|
---|
367 | </h3><p>Returns the spin box's text, including any <a href="#prefix">prefix</a>() and <a href="#suffix">suffix</a>().
|
---|
368 | See the <a href="qspinbox.html#text-prop">"text"</a> property for details.
|
---|
369 | <h3 class=fn>void <a name="textChanged"></a>QSpinBox::textChanged ()<tt> [protected slot]</tt>
|
---|
370 | </h3>
|
---|
371 | This slot is called whenever the user edits the spin box's text.
|
---|
372 |
|
---|
373 | <h3 class=fn><a href="qrect.html">QRect</a> <a name="upRect"></a>QSpinBox::upRect () const
|
---|
374 | </h3>
|
---|
375 | Returns the geometry of the "up" button.
|
---|
376 |
|
---|
377 | <h3 class=fn>void <a name="updateDisplay"></a>QSpinBox::updateDisplay ()<tt> [virtual protected]</tt>
|
---|
378 | </h3>
|
---|
379 | Updates the contents of the embedded <a href="qlineedit.html">QLineEdit</a> to reflect the
|
---|
380 | current value using <a href="#mapValueToText">mapValueToText</a>(). Also enables/disables the
|
---|
381 | up/down push buttons accordingly.
|
---|
382 | <p> <p>See also <a href="#mapValueToText">mapValueToText</a>().
|
---|
383 |
|
---|
384 | <h3 class=fn>const <a href="qvalidator.html">QValidator</a> * <a name="validator"></a>QSpinBox::validator () const
|
---|
385 | </h3>
|
---|
386 | Returns the validator that constrains editing for this spin box if
|
---|
387 | there is any; otherwise returns 0.
|
---|
388 | <p> <p>See also <a href="#setValidator">setValidator</a>() and <a href="qvalidator.html">QValidator</a>.
|
---|
389 |
|
---|
390 | <h3 class=fn>int <a name="value"></a>QSpinBox::value () const
|
---|
391 | </h3><p>Returns the value of the spin box.
|
---|
392 | See the <a href="qspinbox.html#value-prop">"value"</a> property for details.
|
---|
393 | <h3 class=fn>void <a name="valueChange"></a>QSpinBox::valueChange ()<tt> [virtual protected]</tt>
|
---|
394 | </h3>
|
---|
395 | This virtual function is called by <a href="qrangecontrol.html">QRangeControl</a> whenever the
|
---|
396 | value has changed. The QSpinBox reimplementation updates the
|
---|
397 | display and emits the <a href="#valueChanged">valueChanged</a>() signals; if you need
|
---|
398 | additional processing, either reimplement this or connect to one
|
---|
399 | of the valueChanged() signals.
|
---|
400 |
|
---|
401 | <p>Reimplemented from <a href="qrangecontrol.html#valueChange">QRangeControl</a>.
|
---|
402 | <h3 class=fn>void <a name="valueChanged"></a>QSpinBox::valueChanged ( int value )<tt> [signal]</tt>
|
---|
403 | </h3>
|
---|
404 |
|
---|
405 | <p> This signal is emitted every time the value of the spin box
|
---|
406 | changes; the new value is passed in <em>value</em>. This signal will be
|
---|
407 | emitted as a result of a call to <a href="#setValue">setValue</a>(), or because the user
|
---|
408 | changed the value by using a keyboard accelerator or mouse click,
|
---|
409 | etc.
|
---|
410 | <p> Note that the <a href="#valueChanged">valueChanged</a>() signal is emitted <em>every</em> time, not
|
---|
411 | just for the "last" step; i.e. if the user clicks "up" three
|
---|
412 | times, this signal is emitted three times.
|
---|
413 | <p> <p>See also <a href="#value-prop">value</a>.
|
---|
414 |
|
---|
415 | <p>Examples: <a href="listbox-example.html#x1445">listbox/listbox.cpp</a>, <a href="qfd-example.html#x2009">qfd/fontdisplayer.cpp</a>, and <a href="scribble-example.html#x939">scribble/scribble.cpp</a>.
|
---|
416 | <h3 class=fn>void <a name="valueChanged-2"></a>QSpinBox::valueChanged ( const <a href="qstring.html">QString</a> & valueText )<tt> [signal]</tt>
|
---|
417 | </h3>
|
---|
418 |
|
---|
419 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
420 | <p> This signal is emitted whenever the <a href="#valueChanged">valueChanged</a>( int ) signal is
|
---|
421 | emitted, i.e. every time the value of the spin box changes
|
---|
422 | (whatever the cause, e.g. by <a href="#setValue">setValue</a>(), by a keyboard
|
---|
423 | accelerator, by mouse clicks, etc.).
|
---|
424 | <p> The <em>valueText</em> parameter is the same string that is displayed in
|
---|
425 | the edit field of the spin box.
|
---|
426 | <p> <p>See also <a href="#value-prop">value</a>, <a href="#prefix-prop">prefix</a>, <a href="#suffix-prop">suffix</a>, and <a href="#specialValueText-prop">specialValueText</a>.
|
---|
427 |
|
---|
428 | <h3 class=fn>bool <a name="wrapping"></a>QSpinBox::wrapping () const
|
---|
429 | </h3><p>Returns TRUE if it is possible to step the value from the highest value to the lowest value and vice versa; otherwise returns FALSE.
|
---|
430 | See the <a href="qspinbox.html#wrapping-prop">"wrapping"</a> property for details.
|
---|
431 | <hr><h2>Property Documentation</h2>
|
---|
432 | <h3 class=fn><a href="qspinbox.html#ButtonSymbols-enum">ButtonSymbols</a> <a name="buttonSymbols-prop"></a>buttonSymbols</h3>
|
---|
433 | <p>This property holds the current button symbol mode.
|
---|
434 | <p>The possible values can be either <a href="#ButtonSymbols-enum">UpDownArrows</a> or <a href="#ButtonSymbols-enum">PlusMinus</a>.
|
---|
435 | The default is <a href="#ButtonSymbols-enum">UpDownArrows</a>.
|
---|
436 | <p> <p>See also <a href="#ButtonSymbols-enum">ButtonSymbols</a>.
|
---|
437 |
|
---|
438 | <p>Set this property's value with <a href="#setButtonSymbols">setButtonSymbols</a>() and get this property's value with <a href="#buttonSymbols">buttonSymbols</a>().
|
---|
439 | <h3 class=fn><a href="qstring.html">QString</a> <a name="cleanText-prop"></a>cleanText</h3>
|
---|
440 | <p>This property holds the spin box's text with no <a href="#prefix">prefix</a>(), <a href="#suffix">suffix</a>() or leading or trailing whitespace.
|
---|
441 | <p>Get this property's value with <a href="#cleanText">cleanText</a>().
|
---|
442 | <p><p>See also <a href="#text-prop">text</a>, <a href="#prefix-prop">prefix</a>, and <a href="#suffix-prop">suffix</a>.
|
---|
443 |
|
---|
444 | <h3 class=fn>int <a name="lineStep-prop"></a>lineStep</h3>
|
---|
445 | <p>This property holds the line step.
|
---|
446 | <p>When the user uses the arrows to change the spin box's value the
|
---|
447 | value will be incremented/decremented by the amount of the line
|
---|
448 | step.
|
---|
449 | <p> The <a href="#setLineStep">setLineStep</a>() function calls the virtual <a href="qrangecontrol.html#stepChange">stepChange</a>() function
|
---|
450 | if the new line step is different from the previous setting.
|
---|
451 | <p> <p>See also <a href="qrangecontrol.html#setSteps">QRangeControl::setSteps</a>() and <a href="qrangecontrol.html#setRange">setRange</a>().
|
---|
452 |
|
---|
453 | <p>Set this property's value with <a href="#setLineStep">setLineStep</a>() and get this property's value with <a href="#lineStep">lineStep</a>().
|
---|
454 | <h3 class=fn>int <a name="maxValue-prop"></a>maxValue</h3>
|
---|
455 | <p>This property holds the maximum value of the spin box.
|
---|
456 | <p>When setting this property, <a href="#minValue-prop">QSpinBox::minValue</a> is adjusted, if
|
---|
457 | necessary, to ensure that the range remains valid.
|
---|
458 | <p> <p>See also <a href="qrangecontrol.html#setRange">setRange</a>() and <a href="#specialValueText-prop">specialValueText</a>.
|
---|
459 |
|
---|
460 | <p>Set this property's value with <a href="#setMaxValue">setMaxValue</a>() and get this property's value with <a href="#maxValue">maxValue</a>().
|
---|
461 | <h3 class=fn>int <a name="minValue-prop"></a>minValue</h3>
|
---|
462 | <p>This property holds the minimum value of the spin box.
|
---|
463 | <p>When setting this property, <a href="#maxValue-prop">QSpinBox::maxValue</a> is adjusted, if
|
---|
464 | necessary, to ensure that the range remains valid.
|
---|
465 | <p> <p>See also <a href="qrangecontrol.html#setRange">setRange</a>() and <a href="#specialValueText-prop">specialValueText</a>.
|
---|
466 |
|
---|
467 | <p>Set this property's value with <a href="#setMinValue">setMinValue</a>() and get this property's value with <a href="#minValue">minValue</a>().
|
---|
468 | <h3 class=fn><a href="qstring.html">QString</a> <a name="prefix-prop"></a>prefix</h3>
|
---|
469 | <p>This property holds the spin box's prefix.
|
---|
470 | <p>The prefix is prepended to the start of the displayed value.
|
---|
471 | Typical use is to display a unit of measurement or a currency
|
---|
472 | symbol. For example:
|
---|
473 | <p> <pre>
|
---|
474 | sb->setPrefix( "$" );
|
---|
475 | </pre>
|
---|
476 |
|
---|
477 | <p> To turn off the prefix display, set this property to an empty
|
---|
478 | string. The default is no prefix. The prefix is not displayed for
|
---|
479 | the <a href="#minValue">minValue</a>() if <a href="#specialValueText">specialValueText</a>() is not empty.
|
---|
480 | <p> If no prefix is set, <a href="#prefix">prefix</a>() returns <a href="qstring.html#QString-null">QString::null</a>.
|
---|
481 | <p> <p>See also <a href="#suffix-prop">suffix</a>.
|
---|
482 |
|
---|
483 | <p>Set this property's value with <a href="#setPrefix">setPrefix</a>() and get this property's value with <a href="#prefix">prefix</a>().
|
---|
484 | <h3 class=fn><a href="qstring.html">QString</a> <a name="specialValueText-prop"></a>specialValueText</h3>
|
---|
485 | <p>This property holds the special-value text.
|
---|
486 | <p>If set, the spin box will display this text instead of a numeric
|
---|
487 | value whenever the current value is equal to minVal(). Typical use
|
---|
488 | is to indicate that this choice has a special (default) meaning.
|
---|
489 | <p> For example, if your spin box allows the user to choose the margin
|
---|
490 | width in a print dialog and your application is able to
|
---|
491 | automatically choose a good margin width, you can set up the spin
|
---|
492 | box like this:
|
---|
493 | <pre>
|
---|
494 | QSpinBox marginBox( -1, 20, 1, parent, "marginBox" );
|
---|
495 | marginBox-><a href="#setSuffix">setSuffix</a>( " mm" );
|
---|
496 | marginBox-><a href="#setSpecialValueText">setSpecialValueText</a>( "Auto" );
|
---|
497 | </pre>
|
---|
498 |
|
---|
499 | The user will then be able to choose a margin width from 0-20
|
---|
500 | millimeters or select "Auto" to leave it to the application to
|
---|
501 | choose. Your code must then interpret the spin box value of -1 as
|
---|
502 | the user requesting automatic margin width.
|
---|
503 | <p> All values are displayed with the <a href="#prefix">prefix</a>() and <a href="#suffix">suffix</a>() (if set),
|
---|
504 | <em>except</em> for the special value, which only shows the special
|
---|
505 | value text.
|
---|
506 | <p> To turn off the special-value text display, call this function
|
---|
507 | with an empty string. The default is no special-value text, i.e.
|
---|
508 | the numeric value is shown as usual.
|
---|
509 | <p> If no special-value text is set, <a href="#specialValueText">specialValueText</a>() returns
|
---|
510 | <a href="qstring.html#QString-null">QString::null</a>.
|
---|
511 |
|
---|
512 | <p>Set this property's value with <a href="#setSpecialValueText">setSpecialValueText</a>() and get this property's value with <a href="#specialValueText">specialValueText</a>().
|
---|
513 | <h3 class=fn><a href="qstring.html">QString</a> <a name="suffix-prop"></a>suffix</h3>
|
---|
514 | <p>This property holds the suffix of the spin box.
|
---|
515 | <p>The suffix is appended to the end of the displayed value. Typical
|
---|
516 | use is to display a unit of measurement or a currency symbol. For
|
---|
517 | example:
|
---|
518 | <p> <pre>
|
---|
519 | sb->setSuffix( " km" );
|
---|
520 | </pre>
|
---|
521 |
|
---|
522 | <p> To turn off the suffix display, set this property to an empty
|
---|
523 | string. The default is no suffix. The suffix is not displayed for
|
---|
524 | the <a href="#minValue">minValue</a>() if <a href="#specialValueText">specialValueText</a>() is not empty.
|
---|
525 | <p> If no suffix is set, <a href="#suffix">suffix</a>() returns a <a href="qstring.html#QString-null">QString::null</a>.
|
---|
526 | <p> <p>See also <a href="#prefix-prop">prefix</a>.
|
---|
527 |
|
---|
528 | <p>Set this property's value with <a href="#setSuffix">setSuffix</a>() and get this property's value with <a href="#suffix">suffix</a>().
|
---|
529 | <h3 class=fn><a href="qstring.html">QString</a> <a name="text-prop"></a>text</h3>
|
---|
530 | <p>This property holds the spin box's text, including any <a href="#prefix">prefix</a>() and <a href="#suffix">suffix</a>().
|
---|
531 | <p>There is no default text.
|
---|
532 | <p> <p>See also <a href="#value-prop">value</a>.
|
---|
533 |
|
---|
534 | <p>Get this property's value with <a href="#text">text</a>().
|
---|
535 | <h3 class=fn>int <a name="value-prop"></a>value</h3>
|
---|
536 | <p>This property holds the value of the spin box.
|
---|
537 | <p>Set this property's value with <a href="#setValue">setValue</a>() and get this property's value with <a href="#value">value</a>().
|
---|
538 | <p><p>See also <a href="qrangecontrol.html#setValue">QRangeControl::setValue</a>().
|
---|
539 |
|
---|
540 | <h3 class=fn>bool <a name="wrapping-prop"></a>wrapping</h3>
|
---|
541 | <p>This property holds whether it is possible to step the value from the highest value to the lowest value and vice versa.
|
---|
542 | <p>By default, wrapping is turned off.
|
---|
543 | <p> If you have a range of 0..100 and wrapping is off when the user
|
---|
544 | reaches 100 and presses the Up Arrow nothing will happen; but if
|
---|
545 | wrapping is on the value will change from 100 to 0, then to 1,
|
---|
546 | etc. When wrapping is on, navigating past the highest value takes
|
---|
547 | you to the lowest and vice versa.
|
---|
548 | <p> <p>See also <a href="#minValue-prop">minValue</a>, <a href="#maxValue-prop">maxValue</a>, and <a href="qrangecontrol.html#setRange">setRange</a>().
|
---|
549 |
|
---|
550 | <p>Set this property's value with <a href="#setWrapping">setWrapping</a>() and get this property's value with <a href="#wrapping">wrapping</a>().
|
---|
551 | <!-- eof -->
|
---|
552 | <hr><p>
|
---|
553 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
554 | Copyright © 1995-2007
|
---|
555 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
556 | <table width=100% cellspacing=0 border=0><tr>
|
---|
557 | <td>Copyright © 2007
|
---|
558 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
559 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
560 | </table></div></address></body>
|
---|
561 | </html>
|
---|