QRangeControl(3qt)
okay so bestie, buckle up β this is QRangeControl, straight out of the 3qt manual, and honestly it's giving "quiet legend that runs the whole scrollbar economy" π
β¨ NAME β¨
QRangeControl β integer value within a range. That's the whole pitch. No notes. π
β¨ SYNOPSIS β¨
#include <qrangecontrol.h>
Inherited by QDial, QScrollBar, QSlider, and QSpinBox. not me listing the entire friend group π
π Public Members
QRangeControl ()QRangeControl ( int minValue, int maxValue, int lineStep, int pageStep, int value )virtual ~QRangeControl ()int value () constvoid setValue ( int value )void addPage ()void subtractPage ()void addLine ()void subtractLine ()int minValue () constint maxValue () constvoid setRange ( int minValue, int maxValue )void setMinValue ( int minVal )void setMaxValue ( int maxVal )int lineStep () constint pageStep () constvoid setSteps ( int lineStep, int pageStep )int bound ( int v ) const
π¦ Protected Members
int positionFromValue ( int logical_val, int span ) constint valueFromPosition ( int pos, int span ) constvoid directSetValue ( int value )int prevValue () constvirtual void valueChange ()virtual void rangeChange ()virtual void stepChange ()
πΈ DESCRIPTION πΈ
The QRangeControl class provides an integer value within a range. yes that's the whole thing, and yes it carries entire UIs on its back π
Even though it was originally designed for the QScrollBar widget, QRangeControl can also be used alongside other widgets like QSlider and QSpinBox. Here are the five main concepts in the class, and bestie, these are the ones you actually need to know:
- Current value β the bounded integer that
QRangeControlmaintains.value()returns it, and several functions, includingsetValue(), set it. - Minimum β the lowest value that
value()can ever return. Returned byminValue()and set bysetRange()or one of the constructors. - Maximum β the highest value that
value()can ever return. Returned bymaxValue()and set bysetRange()or one of the constructors. - Line step β the smaller of two natural steps that
QRangeControlprovides and typically corresponds to the user pressing an arrow key. The line step is returned bylineStep()and set usingsetSteps(). The functionsaddLine()andsubtractLine()respectively increment and decrement the current value bylineStep(). - Page step β the larger of two natural steps that
QRangeControlprovides and typically corresponds to the user pressing PageUp or PageDown. The page step is returned bypageStep()and set usingsetSteps(). The functionsaddPage()andsubstractPage()respectively increment and decrement the current value bypageStep().
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() or pageStep(). fr fr, it's flexible like that β¨
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().
QRangeControl also provides a function called bound() which lets you force arbitrary integers to be within the allowed range of the range control.
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.
β οΈ Note that you must use multiple inheritance if you plan to implement a widget usingQRangeControlbecauseQRangeControlis not derived fromQWidget. do not skip this one, it will absolutely humble you π
See also Miscellaneous Classes.
π MEMBER FUNCTION DOCUMENTATION π
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. cute little defaults, obsessed π
QRangeControl::QRangeControl ( int minValue, int maxValue, int lineStep, int pageStep, int value )
Constructs a range control whose value can never be smaller than minValue or greater than maxValue, whose line step size is lineStep and page step size is pageStep and whose value is initially value (which is guaranteed to be in range using bound()).
QRangeControl::~QRangeControl () [virtual]
Destroys the range control. she's done, she's leaving, she served π«Ά
void QRangeControl::addLine ()
Equivalent to setValue( value() + lineStep() ).
If the value is changed, then valueChange() is called.
See also subtractLine(), addPage(), and setValue().
void QRangeControl::addPage ()
Equivalent to setValue( value() + pageStep() ).
If the value is changed, then valueChange() is called.
See also subtractPage(), addLine(), and setValue().
int QRangeControl::bound ( int v ) const
Forces the value v to be within the range from minValue() to maxValue() inclusive, and returns the result.
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.
See also setValue(), value(), minValue(), and maxValue().
void QRangeControl::directSetValue ( int value ) [protected]
Sets the range control value directly without calling valueChange().
Forces the new value to be within the legal range.
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. recursion jumpscare, handled π
See also setValue().
int QRangeControl::lineStep () const
Returns the line step.
See also setSteps() and pageStep().
int QRangeControl::maxValue () const
Returns the maximum value of the range.
See also setMaxValue(), setRange(), and minValue().
int QRangeControl::minValue () const
Returns the minimum value of the range.
See also setMinValue(), setRange(), and maxValue().
int QRangeControl::pageStep () const
Returns the page step.
See also setSteps() and lineStep().
int QRangeControl::positionFromValue ( int logical_val, int span ) const [protected]
Converts logical_val to a pixel position. minValue() maps to 0, maxValue() maps to span and other values are distributed evenly in-between.
This function can handle the entire integer range without overflow, providing span is <= 4096.
Calling this method is useful when actually drawing a range control such as a QScrollBar on-screen.
See also valueFromPosition().
int QRangeControl::prevValue () const [protected]
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().
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. the receipts stay, bestie π§Ύ
See also value() and setRange().
void QRangeControl::rangeChange () [virtual protected]
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.
Note that this method is called after the range has changed.
See also setRange(), valueChange(), and stepChange().
Reimplemented in QDial, QSlider, and QSpinBox.
void QRangeControl::setMaxValue ( int maxVal )
Sets the minimum value of the range to maxVal.
If necessary, the minValue() is adjusted so that the range remains valid.
See also maxValue() and setMinValue().
void QRangeControl::setMinValue ( int minVal )
Sets the minimum value of the range to minVal.
If necessary, the maxValue() is adjusted so that the range remains valid.
See also minValue() and setMaxValue().
void QRangeControl::setRange ( int minValue, int maxValue )
Sets the range control's minimum value to minValue and its maximum value to maxValue.
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.
If maxValue is smaller than minValue, minValue becomes the only legal value.
See also minValue() and maxValue().
Examples:
void QRangeControl::setSteps ( int lineStep, int pageStep )
Sets the range's line step to lineStep and page step to pageStep.
Calls the virtual stepChange() function if the new line step or page step are different from the previous settings.
See also lineStep(), pageStep(), and setRange().
void QRangeControl::setValue ( int value )
Sets the range control's value to value and forces it to be within the legal range.
Calls the virtual valueChange() function if the new value is different from the previous value. The old value can still be retrieved using prevValue().
See also value().
void QRangeControl::stepChange () [virtual protected]
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.
Note that this method is called after a step setting has changed.
See also setSteps(), rangeChange(), and valueChange().
void QRangeControl::subtractLine ()
Equivalent to setValue( value() - lineStep() ).
If the value is changed, then valueChange() is called.
See also addLine(), subtractPage(), and setValue().
void QRangeControl::subtractPage ()
Equivalent to setValue( value() - pageStep() ).
If the value is changed, then valueChange() is called.
See also addPage(), subtractLine(), and setValue().
int QRangeControl::value () const
Returns the current range control value. This is guaranteed to be within the range [minValue(), maxValue()].
See also setValue() and prevValue().
void QRangeControl::valueChange () [virtual protected]
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.
Note that this method is called after the value has changed. The previous value can be retrieved using prevValue().
See also setValue(), addPage(), subtractPage(), addLine(), subtractLine(), rangeChange(), and stepChange().
Reimplemented in QDial, QSlider, and QSpinBox.
and that's part one, bestie β there's more where that came from, so don't go anywhere π
int QRangeControl::valueFromPosition ( int pos, int span ) const[protected] β okay so this one is the glow-up ofpositionFromValue(): it takes a pixel positionposand flips it back into a value π¦.0maps tominValue(),spanmaps tomaxValue(), and every other position gets spread out evenly in-between, no cap β¨.
Like, this function can handle the entire integer range without overflow β she's built different, fr fr π .
When is this useful, bestie? When you're out here actually implementing a range control widget yourself, something like QScrollBar, and you need to deal with mouse press events π±οΈ. This function is the one that maps your screen coordinates over to the logical values. Iconic behaviour, honestly.
See also positionFromValue(). π
π SEE ALSO π
π COPYRIGHT π
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. π
π AUTHOR π
Generated automatically from the source code. (no human author, just vibes and a code generator, ngl π€)
π«Ά BUGS π«Ά
Okay so if you find a bug in Qt, please report it like they describe at http://doc.trolltech.com/bughowto.html. Good bug reports help us help you. Thank you!! π Every well-written bug report is a little gift, bestie.
The definitive Qt documentation is provided in HTML format β it lives at $QTDIR/doc/html and you can read it using Qt Assistant or with a web browser π. This man page is just a convenience for the users who prefer man pages, lowkey, because this format is not officially supported by Trolltech. Not officially supported, okay?? just so we're clear.
And if you find errors in this manual page specifically, report them to qt-bugs@trolltech.com π§. Please include the name of the manual page (qrangecontrol.3qt) and the Qt version (3.3.8) β don't make them guess, bestie, give them the receipts π
.
That's the whole page, bestie!! π This one came from Trolltech AS, dated 2 February 2007, and it's the QRangeControl(3qt) man page β so if you ever need to cite it, you've got the source and the date right here. Go forth and range-control the world, you absolute icon πβ¨π¦
π¦ where this page comes from
- fedora 43: qt3-devel-docs 3.3.8b-102.fc43 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- fedora 44: qt3-devel-docs 3.3.8b-103.fc44 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms