Qwt User's Guide
svn
|
#include <qwt_abstract_slider.h>
Inherits QwtDoubleRange.
Inherited by QwtDial, QwtKnob, QwtSlider, and QwtWheel.
Public Types | |
enum | ScrollMode { ScrNone, ScrMouse, ScrTimer, ScrDirect, ScrPage } |
Public Slots | |
virtual void | fitValue (double val) |
virtual void | incValue (int steps) |
virtual void | setReadOnly (bool) |
virtual void | setValue (double val) |
Signals | |
void | sliderMoved (double value) |
void | sliderPressed () |
void | sliderReleased () |
void | valueChanged (double value) |
Public Member Functions | |
virtual void | incPages (int) |
bool | isReadOnly () const |
bool | isValid () const |
virtual double | mass () const |
double | maxValue () const |
double | minValue () const |
Qt::Orientation | orientation () const |
int | pageSize () const |
bool | periodic () const |
QwtAbstractSlider (Qt::Orientation, QWidget *parent=NULL) | |
virtual void | setMass (double val) |
virtual void | setOrientation (Qt::Orientation o) |
void | setPeriodic (bool tf) |
void | setRange (double vmin, double vmax, double vstep=0.0, int pagesize=1) |
void | setStep (double) |
void | setTracking (bool enable) |
void | setUpdateTime (int t) |
void | setValid (bool valid) |
double | step () const |
void | stopMoving () |
double | value () const |
virtual | ~QwtAbstractSlider () |
Protected Member Functions | |
double | exactPrevValue () const |
double | exactValue () const |
virtual void | getScrollMode (const QPoint &pos, ScrollMode &scrollMode, int &direction) const =0 |
virtual double | getValue (const QPoint &p)=0 |
virtual void | keyPressEvent (QKeyEvent *e) |
virtual void | mouseMoveEvent (QMouseEvent *e) |
double | mouseOffset () const |
virtual void | mousePressEvent (QMouseEvent *e) |
virtual void | mouseReleaseEvent (QMouseEvent *e) |
double | prevValue () const |
virtual void | rangeChange () |
int | scrollMode () const |
void | setMouseOffset (double) |
virtual void | setPosition (const QPoint &) |
virtual void | stepChange () |
virtual void | timerEvent (QTimerEvent *e) |
virtual void | valueChange () |
virtual void | wheelEvent (QWheelEvent *e) |
An abstract base class for slider widgets.
QwtAbstractSlider is a base class for slider widgets. It handles mouse events and updates the slider's value accordingly. Derived classes only have to implement the getValue() and getScrollMode() members, and should react to a valueChange(), which normally requires repainting.
Scroll mode
QwtAbstractSlider::QwtAbstractSlider | ( | Qt::Orientation | orientation, |
QWidget * | parent = NULL |
||
) | [explicit] |
Constructor.
orientation | Orientation |
parent | Parent widget |
QwtAbstractSlider::~QwtAbstractSlider | ( | ) | [virtual] |
Destructor.
double QwtDoubleRange::exactPrevValue | ( | ) | const [protected, inherited] |
Returns the exact previous value.
double QwtDoubleRange::exactValue | ( | ) | const [protected, inherited] |
Returns the exact value.
The exact value is the value which QwtDoubleRange::value would return if the value were not adjusted to the step raster. It differs from the current value only if fitValue() or incValue() have been used before. This function is intended for internal use in derived classes.
void QwtAbstractSlider::fitValue | ( | double | value | ) | [virtual, slot] |
Set the slider's value to the nearest integer multiple of the step size.
value | Value |
Reimplemented from QwtDoubleRange.
virtual void QwtAbstractSlider::getScrollMode | ( | const QPoint & | pos, |
ScrollMode & | scrollMode, | ||
int & | direction | ||
) | const [protected, pure virtual] |
Determine what to do when the user presses a mouse button.
This function is abstract and has to be implemented by derived classes. It is called on a mousePress event. The derived class can determine what should happen next in dependence of the position where the mouse was pressed by returning scrolling mode and direction.
pos | point where the mouse was pressed |
scrollMode | The scrolling mode |
direction | direction: 1, 0, or -1. |
virtual double QwtAbstractSlider::getValue | ( | const QPoint & | p | ) | [protected, pure virtual] |
Determine the value corresponding to a specified poind.
This is an abstract virtual function which is called when the user presses or releases a mouse button or moves the mouse. It has to be implemented by the derived class.
p | point |
void QwtDoubleRange::incPages | ( | int | nPages | ) | [virtual, inherited] |
Increment the value by a specified number of pages.
nPages | Number of pages to increment. A negative number decrements the value. |
void QwtAbstractSlider::incValue | ( | int | steps | ) | [virtual, slot] |
Increment the value by a specified number of steps.
steps | number of steps |
Reimplemented from QwtDoubleRange.
bool QwtAbstractSlider::isReadOnly | ( | ) | const |
In read only mode the slider can't be controlled by mouse or keyboard.
bool QwtAbstractSlider::isValid | ( | ) | const [inline] |
Reimplemented from QwtDoubleRange.
void QwtAbstractSlider::keyPressEvent | ( | QKeyEvent * | e | ) | [protected, virtual] |
Handles key events
e | Key event |
Reimplemented in QwtDial, and QwtCompass.
double QwtAbstractSlider::mass | ( | ) | const [virtual] |
double QwtDoubleRange::maxValue | ( | ) | const [inherited] |
Returns the value of the second border of the range.
maxValue returns the value which has been specified as the second parameter in QwtDoubleRange::setRange.
Reimplemented in QwtCounter.
double QwtDoubleRange::minValue | ( | ) | const [inherited] |
Returns the value at the first border of the range.
minValue returns the value which has been specified as the first parameter in setRange().
Reimplemented in QwtCounter.
void QwtAbstractSlider::mouseMoveEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Mouse Move Event handler
e | Mouse event |
double QwtAbstractSlider::mouseOffset | ( | ) | const [protected] |
void QwtAbstractSlider::mousePressEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Mouse press event handler
e | Mouse event |
void QwtAbstractSlider::mouseReleaseEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Mouse Release Event handler
e | Mouse event |
Qt::Orientation QwtAbstractSlider::orientation | ( | ) | const |
int QwtDoubleRange::pageSize | ( | ) | const [inherited] |
Returns the page size in steps.
bool QwtDoubleRange::periodic | ( | ) | const [inherited] |
Returns true if the range is periodic.
double QwtDoubleRange::prevValue | ( | ) | const [protected, inherited] |
Returns the previous value.
void QwtDoubleRange::rangeChange | ( | ) | [protected, virtual, inherited] |
Notify a change of the range.
This virtual function is called whenever the range changes. The default implementation does nothing.
Reimplemented in QwtDial, QwtCounter, and QwtSlider.
int QwtAbstractSlider::scrollMode | ( | ) | const [protected] |
sa ScrollMode
void QwtAbstractSlider::setMass | ( | double | val | ) | [virtual] |
Set the slider's mass for flywheel effect.
If the slider's mass is greater then 0, it will continue to move after the mouse button has been released. Its speed decreases with time at a rate depending on the slider's mass. A large mass means that it will continue to move for a long time.
Derived widgets may overload this function to make it public.
val | New mass in kg |
Reimplemented in QwtWheel.
void QwtAbstractSlider::setMouseOffset | ( | double | offset | ) | [protected] |
void QwtAbstractSlider::setOrientation | ( | Qt::Orientation | o | ) | [virtual] |
void QwtDoubleRange::setPeriodic | ( | bool | tf | ) | [inherited] |
Make the range periodic.
When the range is periodic, the value will be set to a point inside the interval such that
point = value + n * width
if the user tries to set a new value which is outside the range. If the range is nonperiodic (the default), values outside the range will be clipped.
tf | true for a periodic range |
void QwtAbstractSlider::setPosition | ( | const QPoint & | p | ) | [protected, virtual] |
Move the slider to a specified point, adjust the value and emit signals if necessary.
void QwtDoubleRange::setRange | ( | double | vmin, |
double | vmax, | ||
double | vstep = 0.0 , |
||
int | pageSize = 1 |
||
) | [inherited] |
Specify range and step size.
vmin | lower boundary of the interval |
vmax | higher boundary of the interval |
vstep | step width |
pageSize | page size in steps |
void QwtAbstractSlider::setReadOnly | ( | bool | readOnly | ) | [virtual, slot] |
En/Disable read only mode
In read only mode the slider can't be controlled by mouse or keyboard.
readOnly | Enables in case of true |
void QwtDoubleRange::setStep | ( | double | vstep | ) | [inherited] |
Change the step raster.
vstep | new step width |
Reimplemented in QwtCounter.
void QwtAbstractSlider::setTracking | ( | bool | enable | ) |
Enables or disables tracking.
If tracking is enabled, the slider emits a valueChanged() signal whenever its value changes (the default behaviour). If tracking is disabled, the value changed() signal will only be emitted if:
Tracking is enabled by default.
enable | true (enable) or false (disable) tracking. |
void QwtAbstractSlider::setUpdateTime | ( | int | t | ) |
Specify the update interval for automatic scrolling.
t | update interval in milliseconds |
void QwtAbstractSlider::setValid | ( | bool | valid | ) | [inline] |
void QwtAbstractSlider::setValue | ( | double | val | ) | [virtual, slot] |
Move the slider to a specified value.
This function can be used to move the slider to a value which is not an integer multiple of the step size.
val | new value |
Reimplemented from QwtDoubleRange.
void QwtAbstractSlider::sliderMoved | ( | double | value | ) | [signal] |
This signal is emitted when the user moves the slider with the mouse.
value | new value |
void QwtAbstractSlider::sliderPressed | ( | ) | [signal] |
This signal is emitted when the user presses the movable part of the slider (start ScrMouse Mode).
void QwtAbstractSlider::sliderReleased | ( | ) | [signal] |
This signal is emitted when the user releases the movable part of the slider.
double QwtDoubleRange::step | ( | ) | const [inherited] |
void QwtDoubleRange::stepChange | ( | ) | [protected, virtual, inherited] |
Notify a change of the step size.
This virtual function is called whenever the step size changes. The default implementation does nothing.
void QwtAbstractSlider::stopMoving | ( | ) |
Stop updating if automatic scrolling is active.
void QwtAbstractSlider::timerEvent | ( | QTimerEvent * | e | ) | [protected, virtual] |
Qt timer event
e | Timer event |
double QwtDoubleRange::value | ( | ) | const [inherited] |
Returns the current value.
Reimplemented in QwtCounter.
void QwtAbstractSlider::valueChange | ( | ) | [protected, virtual] |
Notify change of value
This function can be reimplemented by derived classes in order to keep track of changes, i.e. repaint the widget. The default implementation emits a valueChanged() signal if tracking is enabled.
Reimplemented from QwtDoubleRange.
void QwtAbstractSlider::valueChanged | ( | double | value | ) | [signal] |
Notify a change of value.
In the default setting (tracking enabled), this signal will be emitted every time the value changes ( see setTracking() ).
value | new value |
void QwtAbstractSlider::wheelEvent | ( | QWheelEvent * | e | ) | [protected, virtual] |
Wheel Event handler
e | Whell event |