You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
295 lines
13 KiB
295 lines
13 KiB
14 years ago
|
'\" 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 <qrangecontrol.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/qrangecontrol.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 Qt documentation is provided in HTML format; it is
|
||
|
located at $QTDIR/doc/html and can be read using Qt 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 (qrangecontrol.3qt) and the Qt
|
||
|
version (3.3.8).
|