📄 qrangecontrol.3qt
字号:
'\" t.TH QRangeControl 3qt "24 January 2005" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQRangeControl \- Integer value within a range.br.PP\fC#include <qrangecontrol.h>\fR.PPInherited 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 "int \fBvalue\fR () const".br.ti -1c.BI "void \fBsetValue\fR ( int ) ".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 "int \fBlineStep\fR () const".br.ti -1c.BI "int \fBpageStep\fR () const".br.ti -1c.BI "void \fBsetSteps\fR ( int " "line" ", int page ) ".br.ti -1c.BI "int \fBbound\fR ( int ) const".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "int \fBpositionFromValue\fR ( int " "val" ", int space ) const".br.ti -1c.BI "int \fBvalueFromPosition\fR ( int " "pos" ", int space ) const".br.ti -1c.BI "void \fBdirectSetValue\fR ( int val ) ".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 DESCRIPTIONThe QRangeControl class provides an integer value within a range..PPIt was originally designed for the QScrollBar widget, but it can also be practical for other purposes such as QSlider and QSpinBox. Here are the five main concepts in the class: .TPThe current value. This is the bounded integer that QRangeControl maintains. value() returns this, and several functions including setValue() set it..TPThe minimum. This is the lowest value value() can ever return. Returned by minValue(), set by setRange() or one of the constructors..TPThe maximum. This is the highest value value() can ever return. Returned by maxValue(), set by setRange() or one of the constructors..TPThe line step. This is the smaller of two natural steps 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() allow easy movement of the current value by lineStep()..TPThe page step. This is the larger of two natural steps QRangeControl provides, and typically corresponds to the user pressing one of the PageUp and PageDown keys. The page step is returned by pageStep() and set using setSteps(). The functions addPage() and substractPage() allow easy movement of the current value by pageStep()..IP.PPNote that 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()+n*lineStep() for integer values of n. Some widgets may allow the user to set any value at all, others may just provide multiples of lineStep()/pageStep()..PPQRangeControl provides three virtual functions that are well-suited e.g. for updating the on-screen representation of range controls and emitting signals, namely valueChange(), rangeChange() and stepChange()..PPFinally, QRangeControl provides a function called bound() which lets you force arbitrary integers to be within the allowed range of the range control..PPWe recommend that all widgets, which inherit QRangeControl, provide at least a signal called valueChanged(), and many widgets will want to provide addStep(), addPage(), substractStep() and substractPage() as slots..PPNote that you have to use multiple inheritance if you plan to implement a widget using QRangeControl, since QRangeControl is not derived from QWidget..SH MEMBER FUNCTION DOCUMENTATION.SH "QRangeControl::QRangeControl ()"Constructs a range control with min value 0, max value 99, line step 1, page step 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.PP\fIvalue\fR is forced to be within the legal range using the bound() method..SH "void QRangeControl::addLine ()"Equivalent to.PP.nf.br setValue( value()+lineStep() ).fiplus a test for numerical overflow.PPIf the value is changed, then valueChange() is called..PPSee also subtractLine(), addPage() and setValue()..SH "void QRangeControl::addPage ()"Equivalent to.PP.nf.br setValue( value()+pageStep() ).fiplus a test for numerical overflow..PPIf the value is changed, then valueChange() is called..PPSee also subtractPage(), addLine() and setValue()..SH "int QRangeControl::bound ( int v ) const"Forces \fIv\fR to be within the range from minValue() to maxValue() inclusive, and returns the result..PPThis 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..PPSee also setValue(), value(), minValue() and maxValue()..SH "void QRangeControl::directSetValue ( int value ) \fC[protected]\fR"Sets the range control value directly without calling valueChange()..PPForces the new value to be within the legal range..PPYou will find few cases only where you have to call this function. However, if you want to change the range controls value inside the overloaded method valueChange() then setValue() would call the function valueChange() again. To avoid this recursion you must use directSetValue() instead..PPSee also setValue()..SH "int QRangeControl::lineStep () const"Returns the current line step..PPSee also setSteps() and pageStep()..SH "int QRangeControl::maxValue () const"Returns the current maximum value of the range..PPSee also setRange() and minValue()..SH "int QRangeControl::minValue () const"Returns the current minimum value of the range..PPSee also setRange() and maxValue()..SH "int QRangeControl::pageStep () const"Returns the current page step..PPSee 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..PPThis function can handle the entire integer range without overflow..PPCallings this method is useful when actually drawing a range control like a QScrollBar on the screen..PPSee 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, since the value is forced to be inside the specified range. When the range control is initially created, this is the same as value()..PPNote that 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 500, setRange( 0, 400 ) makes value() return 400 and prevValue() 500).PPSee also value() and setRange()..SH "void QRangeControl::rangeChange () \fC[virtual protected]\fR"This virtual function is called whenever the range controls range changes. You can reimplement it if you want to be notified when the range changes. The default implementation does nothing..PPNote that this method is called after the range changed..PPSee also setRange(), valueChange() and stepChange()..PPReimplemented in QScrollBar, QSlider and QDial..SH "void QRangeControl::setRange ( int minValue, int maxValue )"Sets the range min value to \fIminValue\fR and the max value to \fImaxValue.\fR.PPCalls the virtual rangeChange() function if one or both of the new min and max 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..PPIf \fImaxValue\fR is smaller than \fIminValue, minValue\fR becomes the only legal value..PPSee also minValue() and maxValue()..PPExamples:.(lxform/xform.cpp.)l.SH "void QRangeControl::setSteps ( int lineStep,int pageStep )"Sets the range line step to \fIlineStep\fR and page step to \fIpageStep.\fR.PPCalls the virtual stepChange() function if the new line step and/or page step are different from the previous settings..PPSee also lineStep(), pageStep() and setRange()..SH "void QRangeControl::setValue ( int value )"Sets the range controls value to \fIvalue\fR and forces it to be within the legal range..PPCalls the virtual valueChange() function if the new value is different from the previous value. The old value can still be retrieved using prevValue()..PPSee also value()..SH "void QRangeControl::stepChange () \fC[virtual protected]\fR"This virtual function is called whenever the range controls line/page step settings changes. You can reimplement it if you want to be notified when the step changes. The default implementation does nothing..PPNote that this method is called after the step settings changed..PPSee also setSteps(), rangeChange() and valueChange()..PPReimplemented in QScrollBar..SH "void QRangeControl::subtractLine ()"Equivalent to.PP.nf.br setValue( value()-lineStep() ).fiplus a test for numerical underflow.PPIf the value is changed, then valueChange() is called..PPSee also addLine(), subtractPage() and setValue()..SH "void QRangeControl::subtractPage ()"Equivalent to.PP.nf.br setValue( value()-pageStep() ).fiplus a test for numerical underflow.PPIf the value is changed, then valueChange() is called..PPSee 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() ]..PPSee 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..PPNote that this method is called after the value changed. The previous value can be retrieved using prevValue()..PPSee also setValue(), addPage(), subtractPage(), addLine(), subtractLine(), rangeChange() and stepChange()..PPReimplemented in QDial, QSlider and QScrollBar..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..PPThis function can handle the entire integer range without overflow..PPCalling this method is useful if you actually implemented a range control widget like QScrollBar and want to handle mouse press events. This function maps then screen coordinates to the logical values..PPSee also positionFromValue()..SH "SEE ALSO".BR http://doc.trolltech.com/qrangecontrol.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports make our job much simpler. Thank you..PIn case of content or formattting problems with this manual page, pleasereport them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qrangecontrol.3qt) and the Qtversion (2.3.10).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -