
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQ3RangeControl class provides an integer value within a range.More...
| Header: | #include <Q3RangeControl> |
| Q3RangeControl() | |
| Q3RangeControl(int minValue, int maxValue, int lineStep, int pageStep, int value) | |
| virtual | ~Q3RangeControl() |
| void | addLine() |
| void | addPage() |
| int | bound(int v) const |
| int | lineStep() const |
| int | maxValue() const |
| int | minValue() const |
| int | pageStep() const |
| void | setMaxValue(int maxVal) |
| void | setMinValue(int minVal) |
| void | setRange(int minValue, int maxValue) |
| void | setSteps(int lineStep, int pageStep) |
| void | setValue(int value) |
| void | subtractLine() |
| void | subtractPage() |
| int | value() const |
| void | directSetValue(int value) |
| int | positionFromValue(int logical_val, int span) const |
| int | prevValue() const |
| virtual void | rangeChange() |
| virtual void | stepChange() |
| virtual void | valueChange() |
| int | valueFromPosition(int pos, int span) const |
TheQ3RangeControl class provides an integer value within a range.
Although originally designed for theQScrollBar widget, theQ3RangeControl can also be used in conjunction with other widgets such asQSlider andQSpinBox. Here are the five main concepts in the class:
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 justminValue() +n *lineStep() for integer values ofn. Some widgets may allow the user to set any value at all; others may just provide multiples oflineStep() orpageStep().
Q3RangeControl provides three virtual functions that are well suited for updating the on-screen representation of range controls and emitting signals:valueChange(),rangeChange() andstepChange().
Q3RangeControl also provides a function calledbound() which lets you force arbitrary integers to be within the allowed range of the range control.
We recommend that all widgets that inheritQ3RangeControl 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 usingQ3RangeControl becauseQ3RangeControl is not derived fromQWidget.
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.
Constructs a range control whose value can never be smaller thanminValue or greater thanmaxValue, whose line step size islineStep and page step size ispageStep and whose value is initiallyvalue (which is guaranteed to be in range usingbound()).
[virtual]Q3RangeControl::~Q3RangeControl()Destroys the range control
Equivalent tosetValue(value() + lineStep()).
If the value is changed, thenvalueChange() is called.
See alsosubtractLine(),addPage(), andsetValue().
Equivalent tosetValue(value() + pageStep()).
If the value is changed, thenvalueChange() is called.
See alsosubtractPage(),addLine(), andsetValue().
Forces the valuev to be within the range fromminValue() tomaxValue() inclusive, and returns the result.
This function is provided so that you can easily force other numbers thanvalue() into the allowed range. You do not need to call it in order to useQ3RangeControl itself.
See alsosetValue(),value(),minValue(), andmaxValue().
[protected]void Q3RangeControl::directSetValue(int value)Sets the range controlvalue directly without callingvalueChange().
Forces the newvalue 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 methodvalueChange(),setValue() would call the functionvalueChange() again. To avoid this recursion you must use directSetValue() instead.
See alsosetValue().
Returns the line step.
See alsosetSteps() andpageStep().
Returns the maximum value of the range.
See alsosetMaxValue(),setRange(), andminValue().
Returns the minimum value of the range.
See alsosetMinValue(),setRange(), andmaxValue().
Returns the page step.
See alsosetSteps() andlineStep().
[protected]int Q3RangeControl::positionFromValue(int logical_val,int span) constConvertslogical_val to a pixel position.minValue() maps to 0,maxValue() maps tospan and other values are distributed evenly in-between.
This function can handle the entire integer range without overflow, providingspan is <= 4096.
Calling this method is useful when actually drawing a range control such as aQScrollBar on-screen.
See alsovalueFromPosition().
[protected]int Q3RangeControl::prevValue() constReturns 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 asvalue().
prevValue() can be outside the current legal range if a call tosetRange() causes the current value to change. For example, if the range was [0, 1000] and the current value is 500,setRange(0, 400) makesvalue() return 400 and prevValue() return 500.
See alsovalue() andsetRange().
[virtual protected]void Q3RangeControl::rangeChange()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 alsosetRange(),valueChange(), andstepChange().
Sets the minimum value of the range tomaxVal.
If necessary, theminValue() is adjusted so that the range remains valid.
See alsomaxValue() andsetMinValue().
Sets the minimum value of the range tominVal.
If necessary, themaxValue() is adjusted so that the range remains valid.
See alsominValue() andsetMaxValue().
Sets the range control's minimum value tominValue and its maximum value tomaxValue.
Calls the virtualrangeChange() function if one or both of the new minimum and maximum values are different from the previous setting. Calls the virtualvalueChange() function if the current value is adjusted because it was outside the new range.
IfmaxValue is smaller thanminValue,minValue becomes the only legal value.
See alsominValue() andmaxValue().
Sets the range's line step tolineStep and page step topageStep.
Calls the virtualstepChange() function if the new line step or page step are different from the previous settings.
See alsolineStep(),pageStep(), andsetRange().
Sets the range control's value tovalue and forces it to be within the legal range.
Calls the virtualvalueChange() function if the new value is different from the previous value. The old value can still be retrieved usingprevValue().
See alsovalue().
[virtual protected]void Q3RangeControl::stepChange()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 alsosetSteps(),rangeChange(), andvalueChange().
Equivalent tosetValue(value() - lineStep()).
If the value is changed, thenvalueChange() is called.
See alsoaddLine(),subtractPage(), andsetValue().
Equivalent tosetValue(value() - pageStep()).
If the value is changed, thenvalueChange() is called.
See alsoaddPage(),subtractLine(), andsetValue().
Returns the current range control value. This is guaranteed to be within the range [minValue(),maxValue()].
See alsosetValue() andprevValue().
[virtual protected]void Q3RangeControl::valueChange()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 usingprevValue().
See alsosetValue(),addPage(),subtractPage(),addLine(),subtractLine(),rangeChange(), andstepChange().
[protected]int Q3RangeControl::valueFromPosition(int pos,int span) constConverts the pixel positionpos to a value. 0 maps tominValue(),span maps tomaxValue() and other values are distributed evenly in-between.
This function can handle the entire integer range without overflow.
Calling this method is useful if you actually implemented a range control widget such asQScrollBar and want to handle mouse press events. This function then maps screen coordinates to the logical values.
See alsopositionFromValue().
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.