summaryrefslogtreecommitdiffstats
path: root/doc/man/man3/tqrangecontrol.3qt
blob: 1623e5c5cde58dd6d25950c80c93e7070022813a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
'\" t
.TH QRangeControl 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA.  All rights reserved.  See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QRangeControl \- Integer value within a range
.SH SYNOPSIS
\fC#include <ntqrangecontrol.h>\fR
.PP
Inherited by QDial, QScrollBar, QSlider, and QSpinBox.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBQRangeControl\fR ()"
.br
.ti -1c
.BI "\fBQRangeControl\fR ( int minValue, int maxValue, int lineStep, int pageStep, int value )"
.br
.ti -1c
.BI "virtual \fB~QRangeControl\fR ()"
.br
.ti -1c
.BI "int \fBvalue\fR () const"
.br
.ti -1c
.BI "void \fBsetValue\fR ( int value )"
.br
.ti -1c
.BI "void \fBaddPage\fR ()"
.br
.ti -1c
.BI "void \fBsubtractPage\fR ()"
.br
.ti -1c
.BI "void \fBaddLine\fR ()"
.br
.ti -1c
.BI "void \fBsubtractLine\fR ()"
.br
.ti -1c
.BI "int \fBminValue\fR () const"
.br
.ti -1c
.BI "int \fBmaxValue\fR () const"
.br
.ti -1c
.BI "void \fBsetRange\fR ( int minValue, int maxValue )"
.br
.ti -1c
.BI "void \fBsetMinValue\fR ( int minVal )"
.br
.ti -1c
.BI "void \fBsetMaxValue\fR ( int maxVal )"
.br
.ti -1c
.BI "int \fBlineStep\fR () const"
.br
.ti -1c
.BI "int \fBpageStep\fR () const"
.br
.ti -1c
.BI "void \fBsetSteps\fR ( int lineStep, int pageStep )"
.br
.ti -1c
.BI "int \fBbound\fR ( int v ) const"
.br
.in -1c
.SS "Protected Members"
.in +1c
.ti -1c
.BI "int \fBpositionFromValue\fR ( int logical_val, int span ) const"
.br
.ti -1c
.BI "int \fBvalueFromPosition\fR ( int pos, int span ) const"
.br
.ti -1c
.BI "void \fBdirectSetValue\fR ( int value )"
.br
.ti -1c
.BI "int \fBprevValue\fR () const"
.br
.ti -1c
.BI "virtual void \fBvalueChange\fR ()"
.br
.ti -1c
.BI "virtual void \fBrangeChange\fR ()"
.br
.ti -1c
.BI "virtual void \fBstepChange\fR ()"
.br
.in -1c
.SH DESCRIPTION
The QRangeControl class provides an integer value within a range.
.PP
Although originally designed for the QScrollBar widget, the QRangeControl can also be used in conjunction with other widgets such as QSlider and QSpinBox. Here are the five main concepts in the class:
.PP
<ol type=1>
.IP 1
\fICurrent value\fR The bounded integer that QRangeControl maintains. value() returns it, and several functions, including setValue(), set it.
.IP 2
\fIMinimum\fR The lowest value that value() can ever return. Returned by minValue() and set by setRange() or one of the constructors.
.IP 3
\fIMaximum\fR The highest value that value() can ever return. Returned by maxValue() and set by setRange() or one of the constructors.
.IP 4
\fILine step\fR The smaller of two natural steps that QRangeControl provides and typically corresponds to the user pressing an arrow key. The line step is returned by lineStep() and set using setSteps(). The functions addLine() and subtractLine() respectively increment and decrement the current value by lineStep().
.IP 5
\fIPage step\fR The larger of two natural steps that QRangeControl provides and typically corresponds to the user pressing PageUp or PageDown. The page step is returned by pageStep() and set using setSteps(). The functions addPage() and substractPage() respectively increment and decrement the current value by pageStep().
.IP
.PP
Unity (1) may be viewed as a third step size. setValue() lets you set the current value to any integer in the allowed range, not just minValue() + \fIn\fR * lineStep() for integer values of \fIn\fR. Some widgets may allow the user to set any value at all; others may just provide multiples of lineStep() or pageStep().
.PP
QRangeControl provides three virtual functions that are well suited for updating the on-screen representation of range controls and emitting signals: valueChange(), rangeChange() and stepChange().
.PP
QRangeControl also provides a function called bound() which lets you force arbitrary integers to be within the allowed range of the range control.
.PP
We recommend that all widgets that inherit QRangeControl provide at least a signal called valueChanged(); many widgets will want to provide addStep(), addPage(), substractStep() and substractPage() as slots.
.PP
Note that you must use multiple inheritance if you plan to implement a widget using QRangeControl because QRangeControl is not derived from QWidget.
.PP
See also Miscellaneous Classes.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QRangeControl::QRangeControl ()"
Constructs a range control with a minimum value of 0, maximum value of 99, line step of 1, page step of 10 and initial value 0.
.SH "QRangeControl::QRangeControl ( int minValue, int maxValue, int lineStep, int pageStep, int value )"
Constructs a range control whose value can never be smaller than \fIminValue\fR or greater than \fImaxValue\fR, whose line step size is \fIlineStep\fR and page step size is \fIpageStep\fR and whose value is initially \fIvalue\fR (which is guaranteed to be in range using bound()).
.SH "QRangeControl::~QRangeControl ()\fC [virtual]\fR"
Destroys the range control
.SH "void QRangeControl::addLine ()"
Equivalent to \fCsetValue( value() + lineStep() )\fR.
.PP
If the value is changed, then valueChange() is called.
.PP
See also subtractLine(), addPage(), and setValue().
.SH "void QRangeControl::addPage ()"
Equivalent to \fCsetValue( value() + pageStep() )\fR.
.PP
If the value is changed, then valueChange() is called.
.PP
See also subtractPage(), addLine(), and setValue().
.SH "int QRangeControl::bound ( int v ) const"
Forces the value \fIv\fR to be within the range from minValue() to maxValue() inclusive, and returns the result.
.PP
This function is provided so that you can easily force other numbers than value() into the allowed range. You do not need to call it in order to use QRangeControl itself.
.PP
See also setValue(), value(), minValue(), and maxValue().
.SH "void QRangeControl::directSetValue ( int value )\fC [protected]\fR"
Sets the range control \fIvalue\fR directly without calling valueChange().
.PP
Forces the new \fIvalue\fR to be within the legal range.
.PP
You will rarely have to call this function. However, if you want to change the range control's value inside the overloaded method valueChange(), setValue() would call the function valueChange() again. To avoid this recursion you must use directSetValue() instead.
.PP
See also setValue().
.SH "int QRangeControl::lineStep () const"
Returns the line step.
.PP
See also setSteps() and pageStep().
.SH "int QRangeControl::maxValue () const"
Returns the maximum value of the range.
.PP
See also setMaxValue(), setRange(), and minValue().
.SH "int QRangeControl::minValue () const"
Returns the minimum value of the range.
.PP
See also setMinValue(), setRange(), and maxValue().
.SH "int QRangeControl::pageStep () const"
Returns the page step.
.PP
See also setSteps() and lineStep().
.SH "int QRangeControl::positionFromValue ( int logical_val, int span ) const\fC [protected]\fR"
Converts \fIlogical_val\fR to a pixel position. minValue() maps to 0, maxValue() maps to \fIspan\fR and other values are distributed evenly in-between.
.PP
This function can handle the entire integer range without overflow, providing \fIspan\fR is <= 4096.
.PP
Calling this method is useful when actually drawing a range control such as a QScrollBar on-screen.
.PP
See also valueFromPosition().
.SH "int QRangeControl::prevValue () const\fC [protected]\fR"
Returns the previous value of the range control. "Previous value" means the value before the last change occurred. Setting a new range may affect the value, too, because the value is forced to be inside the specified range. When the range control is initially created, this is the same as value().
.PP
prevValue() can be outside the current legal range if a call to setRange() causes the current value to change. For example, if the range was [0, 1000] and the current value is 500, setRange(0, 400) makes value() return 400 and prevValue() return 500.
.PP
See also value() and setRange().
.SH "void QRangeControl::rangeChange ()\fC [virtual protected]\fR"
This virtual function is called whenever the range control's range changes. You can reimplement it if you want to be notified when the range changes. The default implementation does nothing.
.PP
Note that this method is called after the range has changed.
.PP
See also setRange(), valueChange(), and stepChange().
.PP
Reimplemented in QDial, QSlider, and QSpinBox.
.SH "void QRangeControl::setMaxValue ( int maxVal )"
Sets the minimum value of the range to \fImaxVal\fR.
.PP
If necessary, the minValue() is adjusted so that the range remains valid.
.PP
See also maxValue() and setMinValue().
.SH "void QRangeControl::setMinValue ( int minVal )"
Sets the minimum value of the range to \fIminVal\fR.
.PP
If necessary, the maxValue() is adjusted so that the range remains valid.
.PP
See also minValue() and setMaxValue().
.SH "void QRangeControl::setRange ( int minValue, int maxValue )"
Sets the range control's minimum value to \fIminValue\fR and its maximum value to \fImaxValue\fR.
.PP
Calls the virtual rangeChange() function if one or both of the new minimum and maximum values are different from the previous setting. Calls the virtual valueChange() function if the current value is adjusted because it was outside the new range.
.PP
If \fImaxValue\fR is smaller than \fIminValue\fR, \fIminValue\fR becomes the only legal value.
.PP
See also minValue() and maxValue().
.PP
Examples:
.)l listbox/listbox.cpp, t12/lcdrange.cpp, t5/main.cpp, t6/main.cpp, t8/lcdrange.cpp, and xform/xform.cpp.
.SH "void QRangeControl::setSteps ( int lineStep, int pageStep )"
Sets the range's line step to \fIlineStep\fR and page step to \fIpageStep\fR.
.PP
Calls the virtual stepChange() function if the new line step or page step are different from the previous settings.
.PP
See also lineStep(), pageStep(), and setRange().
.SH "void QRangeControl::setValue ( int value )"
Sets the range control's value to \fIvalue\fR and forces it to be within the legal range.
.PP
Calls the virtual valueChange() function if the new value is different from the previous value. The old value can still be retrieved using prevValue().
.PP
See also value().
.SH "void QRangeControl::stepChange ()\fC [virtual protected]\fR"
This virtual function is called whenever the range control's line or page step settings change. You can reimplement it if you want to be notified when the step changes. The default implementation does nothing.
.PP
Note that this method is called after a step setting has changed.
.PP
See also setSteps(), rangeChange(), and valueChange().
.SH "void QRangeControl::subtractLine ()"
Equivalent to \fCsetValue( value() - lineStep() )\fR.
.PP
If the value is changed, then valueChange() is called.
.PP
See also addLine(), subtractPage(), and setValue().
.SH "void QRangeControl::subtractPage ()"
Equivalent to \fCsetValue( value() - pageStep() )\fR.
.PP
If the value is changed, then valueChange() is called.
.PP
See also addPage(), subtractLine(), and setValue().
.SH "int QRangeControl::value () const"
Returns the current range control value. This is guaranteed to be within the range [minValue(), maxValue()].
.PP
See also setValue() and prevValue().
.SH "void QRangeControl::valueChange ()\fC [virtual protected]\fR"
This virtual function is called whenever the range control value changes. You can reimplement it if you want to be notified when the value changes. The default implementation does nothing.
.PP
Note that this method is called after the value has changed. The previous value can be retrieved using prevValue().
.PP
See also setValue(), addPage(), subtractPage(), addLine(), subtractLine(), rangeChange(), and stepChange().
.PP
Reimplemented in QDial, QSlider, and QSpinBox.
.SH "int QRangeControl::valueFromPosition ( int pos, int span ) const\fC [protected]\fR"
Converts the pixel position \fIpos\fR to a value. 0 maps to minValue(), \fIspan\fR maps to maxValue() and other values are distributed evenly in-between.
.PP
This function can handle the entire integer range without overflow.
.PP
Calling this method is useful if you actually implemented a range control widget such as QScrollBar and want to handle mouse press events. This function then maps screen coordinates to the logical values.
.PP
See also positionFromValue().

.SH "SEE ALSO"
.BR http://doc.trolltech.com/ntqrangecontrol.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive TQt documentation is provided in HTML format; it is
located at $QTDIR/doc/html and can be read using TQt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech. 
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (tqrangecontrol.3qt) and the Qt
version (3.3.8).