QwtSlider Class Reference

The Slider Widget. More...

#include <qwt_slider.h>

Inheritance diagram for QwtSlider:

Inheritance graph
[legend]

List of all members.

Public Types

enum  BackgroundStyle {
  Trough = 0x01,
  Groove = 0x02
}
typedef QFlags< BackgroundStyleBackgroundStyles
enum  ScalePos {
  NoScale,
  LeftScale,
  RightScale,
  TopScale,
  BottomScale
}
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

bool autoScale () const
BackgroundStyles backgroundStyle () const
int borderWidth () const
QSize handleSize () const
virtual void incPages (int)
bool isReadOnly () const
bool isValid () const
virtual double mass () const
double maxValue () const
virtual QSize minimumSizeHint () const
double minValue () const
Qt::Orientation orientation () const
int pageSize () const
bool periodic () const
 QwtSlider (QWidget *parent, Qt::Orientation=Qt::Horizontal, ScalePos=NoScale, BackgroundStyles=Trough)
const QwtScaleDrawscaleDraw () const
QwtScaleEnginescaleEngine ()
const QwtScaleEnginescaleEngine () const
const QwtScaleMapscaleMap () const
int scaleMaxMajor () const
int scaleMaxMinor () const
ScalePos scalePosition () const
void setAutoScale ()
void setBackgroundStyle (BackgroundStyles)
void setBorderWidth (int bw)
void setHandleSize (const QSize &)
void setHandleSize (int width, int height)
virtual void setMass (double val)
virtual void setOrientation (Qt::Orientation)
void setPeriodic (bool tf)
void setRange (double vmin, double vmax, double vstep=0.0, int pagesize=1)
void setScale (const QwtScaleDiv &)
void setScale (const QwtInterval &, double step=0.0)
void setScale (double vmin, double vmax, double step=0.0)
void setScaleDraw (QwtScaleDraw *)
void setScaleEngine (QwtScaleEngine *)
void setScaleMaxMajor (int ticks)
void setScaleMaxMinor (int ticks)
void setScalePosition (ScalePos s)
void setSpacing (int)
void setStep (double)
void setTracking (bool enable)
void setUpdateTime (int t)
void setValid (bool valid)
virtual QSize sizeHint () const
int spacing () const
double step () const
void stopMoving ()
double value () const

Protected Member Functions

QwtAbstractScaleDrawabstractScaleDraw ()
const QwtAbstractScaleDrawabstractScaleDraw () const
virtual void changeEvent (QEvent *)
virtual void drawHandle (QPainter *, const QRect &, int pos) const
virtual void drawSlider (QPainter *, const QRect &) const
double exactPrevValue () const
double exactValue () const
virtual void getScrollMode (const QPoint &p, QwtAbstractSlider::ScrollMode &, int &direction) const
virtual double getValue (const QPoint &p)
virtual void keyPressEvent (QKeyEvent *e)
virtual void mouseMoveEvent (QMouseEvent *e)
double mouseOffset () const
virtual void mousePressEvent (QMouseEvent *e)
virtual void mouseReleaseEvent (QMouseEvent *e)
virtual void paintEvent (QPaintEvent *)
double prevValue () const
virtual void rangeChange ()
void rescale (double vmin, double vmax, double step=0.0)
virtual void resizeEvent (QResizeEvent *)
virtual void scaleChange ()
QwtScaleDrawscaleDraw ()
int scrollMode () const
void setAbstractScaleDraw (QwtAbstractScaleDraw *)
void setMouseOffset (double)
virtual void setPosition (const QPoint &)
virtual void stepChange ()
virtual void timerEvent (QTimerEvent *e)
int transform (double v) const
virtual void valueChange ()
virtual void wheelEvent (QWheelEvent *e)


Detailed Description

The Slider Widget.

QwtSlider is a slider widget which operates on an interval of type double. QwtSlider supports different layouts as well as a scale.

sliders.png

See also:
QwtAbstractSlider and QwtAbstractScale for the descriptions of the inherited members.

Member Typedef Documentation

Background styles.


Member Enumeration Documentation

Background style.

See also:
QwtSlider()
Enumerator:
Trough  Trough background.
Groove  Groove.

Scale position. QwtSlider tries to enforce valid combinations of its orientation and scale position:

  • Qt::Horizonal combines with NoScale, TopScale and BottomScale
  • Qt::Vertical combines with NoScale, LeftScale and RightScale

See also:
QwtSlider()
Enumerator:
NoScale  The slider has no scale.
LeftScale  The scale is left of the slider.
RightScale  The scale is right of the slider.
TopScale  The scale is above of the slider.
BottomScale  The scale is below of the slider.

Scroll mode

See also:
getScrollMode()
Enumerator:
ScrNone  Scrolling switched off. Don't change the value.
ScrMouse  Change the value while the user keeps the button pressed and moves the mouse.
ScrTimer  Automatic scrolling. Increment the value in the specified direction as long as the user keeps the button pressed.
ScrPage  Automatic scrolling. Same as ScrTimer, but increment by page size.


Constructor & Destructor Documentation

QwtSlider::QwtSlider ( QWidget *  parent,
Qt::Orientation  orientation = Qt::Horizontal,
ScalePos  scalePos = NoScale,
BackgroundStyles  bgStyle = Trough 
) [explicit]

Constructor.

Parameters:
parent parent widget
orientation Orientation of the slider. Can be Qt::Horizontal or Qt::Vertical. Defaults to Qt::Horizontal.
scalePos Position of the scale. Defaults to QwtSlider::NoScale.
bgStyle Background style. QwtSlider::Trough draws the slider button in a trough, QwtSlider::Slot draws a slot underneath the button. An or-combination of both may also be used. The default is QwtSlider::Trough.
QwtSlider enforces valid combinations of its orientation and scale position. If the combination is invalid, the scale position will be set to NoScale. Valid combinations are:
  • Qt::Horizonal with NoScale, TopScale, or BottomScale;
  • Qt::Vertical with NoScale, LeftScale, or RightScale.


Member Function Documentation

QwtAbstractScaleDraw * QwtAbstractScale::abstractScaleDraw (  )  [protected, inherited]

Returns:
Scale draw
See also:
setAbstractScaleDraw()

const QwtAbstractScaleDraw * QwtAbstractScale::abstractScaleDraw (  )  const [protected, inherited]

Returns:
Scale draw
See also:
setAbstractScaleDraw()

bool QwtAbstractScale::autoScale (  )  const [inherited]

Returns:
true if autoscaling is enabled

QwtSlider::BackgroundStyles QwtSlider::backgroundStyle (  )  const

Returns:
the background style.

int QwtSlider::borderWidth (  )  const

Returns:
the border width.
See also:
setBorderWidth()

void QwtSlider::changeEvent ( QEvent *  event  )  [protected, virtual]

Qt change event handler.

void QwtSlider::drawHandle ( QPainter *  painter,
const QRect &  sliderRect,
int  pos 
) const [protected, virtual]

Draw the thumb at a position

Parameters:
painter Painter
sliderRect Bounding rectangle of the slider
pos Position of the slider thumb

void QwtSlider::drawSlider ( QPainter *  painter,
const QRect &  sliderRect 
) const [protected, virtual]

Draw the slider into the specified rectangle.

Parameters:
painter Painter
sliderRect Bounding rectangle of the slider

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, inherited]

Set the slider's value to the nearest integer multiple of the step size.

Parameters:
value Value
See also:
setValue(), incValue()

Reimplemented from QwtDoubleRange.

void QwtSlider::getScrollMode ( const QPoint &  p,
QwtAbstractSlider::ScrollMode scrollMode,
int &  direction 
) const [protected, virtual]

Determine scrolling mode and direction.

Parameters:
p point
scrollMode Scrolling mode
direction Direction

Implements QwtAbstractSlider.

double QwtSlider::getValue ( const QPoint &  pos  )  [protected, virtual]

Determine the value corresponding to a specified mouse location.

Parameters:
pos Mouse position

Implements QwtAbstractSlider.

QSize QwtSlider::handleSize (  )  const

Returns:
Size of the handle.
See also:
setHandleSize()

void QwtDoubleRange::incPages ( int  nPages  )  [virtual, inherited]

Increment the value by a specified number of pages.

Parameters:
nPages Number of pages to increment. A negative number decrements the value.
Warning:
The Page size is specified in the constructor.

void QwtAbstractSlider::incValue ( int  steps  )  [virtual, slot, inherited]

Increment the value by a specified number of steps.

Parameters:
steps number of steps
See also:
setValue()

Reimplemented from QwtDoubleRange.

bool QwtAbstractSlider::isReadOnly (  )  const [inherited]

In read only mode the slider can't be controlled by mouse or keyboard.

Returns:
true if read only
See also:
setReadOnly()

bool QwtAbstractSlider::isValid (  )  const [inline, inherited]

See also:
QwtDblRange::isValid()

Reimplemented from QwtDoubleRange.

void QwtAbstractSlider::keyPressEvent ( QKeyEvent *  e  )  [protected, virtual, inherited]

Handles key events

  • Key_Down, KeyLeft
    Decrement by 1
  • Key_Up, Key_Right
    Increment by 1

Parameters:
e Key event
See also:
isReadOnly()

Reimplemented in QwtCompass, and QwtDial.

double QwtAbstractSlider::mass (  )  const [virtual, inherited]

Returns:
mass
See also:
setMass()

Reimplemented in QwtWheel.

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.

See also:
setRange()

Reimplemented in QwtCounter.

QSize QwtSlider::minimumSizeHint (  )  const [virtual]

Return a minimum size hint.

Warning:
The return value of QwtSlider::minimumSizeHint() depends on the font and the scale.

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().

See also:
setRange()

Reimplemented in QwtCounter.

void QwtAbstractSlider::mouseMoveEvent ( QMouseEvent *  e  )  [protected, virtual, inherited]

Mouse Move Event handler

Parameters:
e Mouse event

double QwtAbstractSlider::mouseOffset (  )  const [protected, inherited]

See also:
setMouseOffset()

void QwtAbstractSlider::mousePressEvent ( QMouseEvent *  e  )  [protected, virtual, inherited]

Mouse press event handler

Parameters:
e Mouse event

void QwtAbstractSlider::mouseReleaseEvent ( QMouseEvent *  e  )  [protected, virtual, inherited]

Mouse Release Event handler

Parameters:
e Mouse event

Qt::Orientation QwtAbstractSlider::orientation (  )  const [inherited]

Returns:
Orientation
See also:
setOrientation()

int QwtDoubleRange::pageSize (  )  const [inherited]

Returns the page size in steps.

void QwtSlider::paintEvent ( QPaintEvent *  event  )  [protected, virtual]

Qt paint event

Parameters:
event Paint event

bool QwtDoubleRange::periodic (  )  const [inherited]

Returns true if the range is periodic.

See also:
setPeriodic()

double QwtDoubleRange::prevValue (  )  const [protected, inherited]

Returns the previous value.

void QwtSlider::rangeChange (  )  [protected, virtual]

Notify change of range.

Reimplemented from QwtDoubleRange.

void QwtAbstractScale::rescale ( double  vmin,
double  vmax,
double  stepSize = 0.0 
) [protected, inherited]

Recalculate the scale division and update the scale draw.

Parameters:
vmin Lower limit of the scale interval
vmax Upper limit of the scale interval
stepSize Major step size
See also:
scaleChange()

void QwtSlider::resizeEvent ( QResizeEvent *   )  [protected, virtual]

Qt resize event.

void QwtSlider::scaleChange (  )  [protected, virtual]

Notify changed scale.

Reimplemented from QwtAbstractScale.

QwtScaleDraw * QwtSlider::scaleDraw (  )  [protected]

Returns:
the scale draw of the slider
See also:
setScaleDraw()

const QwtScaleDraw * QwtSlider::scaleDraw (  )  const

Returns:
the scale draw of the slider
See also:
setScaleDraw()

QwtScaleEngine * QwtAbstractScale::scaleEngine (  )  [inherited]

Returns:
Scale engine
See also:
setScaleEngine()

const QwtScaleEngine * QwtAbstractScale::scaleEngine (  )  const [inherited]

Returns:
Scale engine
See also:
setScaleEngine()

const QwtScaleMap & QwtAbstractScale::scaleMap (  )  const [inherited]

int QwtAbstractScale::scaleMaxMajor (  )  const [inherited]

Returns:
Max. number of major tick intervals The default value is 5.

int QwtAbstractScale::scaleMaxMinor (  )  const [inherited]

Returns:
Max. number of minor tick intervals The default value is 3.

QwtSlider::ScalePos QwtSlider::scalePosition (  )  const

Return the scale position.

int QwtAbstractSlider::scrollMode (  )  const [protected, inherited]

sa ScrollMode

void QwtAbstractScale::setAbstractScaleDraw ( QwtAbstractScaleDraw scaleDraw  )  [protected, inherited]

Set a scale draw.

scaleDraw has to be created with new and will be deleted in ~QwtAbstractScale or the next call of setAbstractScaleDraw.

void QwtAbstractScale::setAutoScale (  )  [inherited]

Advise the widget to control the scale range internally.

Autoscaling is on by default.

See also:
setScale(), autoScale()

void QwtSlider::setBackgroundStyle ( BackgroundStyles  style  ) 

Set the background style.

void QwtSlider::setBorderWidth ( int  width  ) 

Change the slider's border width.

Parameters:
width Border width

void QwtSlider::setHandleSize ( const QSize &  size  ) 

Set the slider's handle size.

Parameters:
size New size
See also:
handleSize()

void QwtSlider::setHandleSize ( int  width,
int  height 
)

Set the slider's handle size.

Parameters:
width Width
height Height
See also:
handleSize()

void QwtAbstractSlider::setMass ( double  val  )  [virtual, inherited]

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.

Parameters:
val New mass in kg
See also:
mass()

Reimplemented in QwtWheel.

void QwtAbstractSlider::setMouseOffset ( double  offset  )  [protected, inherited]

See also:
mouseOffset()

void QwtSlider::setOrientation ( Qt::Orientation  o  )  [virtual]

Set the orientation.

Parameters:
o Orientation. Allowed values are Qt::Horizontal and Qt::Vertical.
If the new orientation and the old scale position are an invalid combination, the scale position will be set to QwtSlider::NoScale.
See also:
QwtAbstractSlider::orientation()

Reimplemented from QwtAbstractSlider.

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.

Parameters:
tf true for a periodic range

void QwtAbstractSlider::setPosition ( const QPoint &  p  )  [protected, virtual, inherited]

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.

Parameters:
vmin lower boundary of the interval
vmax higher boundary of the interval
vstep step width
pageSize page size in steps
Warning:
  • A change of the range changes the value if it lies outside the new range. The current value will *not* be adjusted to the new step raster.
  • vmax < vmin is allowed.
  • If the step size is left out or set to zero, it will be set to 1/100 of the interval length.
  • If the step size has an absurd value, it will be corrected to a better one.

void QwtAbstractSlider::setReadOnly ( bool  readOnly  )  [virtual, slot, inherited]

En/Disable read only mode

In read only mode the slider can't be controlled by mouse or keyboard.

Parameters:
readOnly Enables in case of true
See also:
isReadOnly()

void QwtAbstractScale::setScale ( const QwtScaleDiv scaleDiv  )  [inherited]

Specify a scale.

Disable autoscaling and define a scale by a scale division

Parameters:
scaleDiv Scale division
See also:
setAutoScale()

void QwtAbstractScale::setScale ( const QwtInterval interval,
double  stepSize = 0.0 
) [inherited]

Specify a scale.

Disable autoscaling and define a scale by an interval and a step size

Parameters:
interval Interval
stepSize major step size
See also:
setAutoScale()

void QwtAbstractScale::setScale ( double  vmin,
double  vmax,
double  stepSize = 0.0 
) [inherited]

Specify a scale.

Disable autoscaling and define a scale by an interval and a step size

Parameters:
vmin lower limit of the scale interval
vmax upper limit of the scale interval
stepSize major step size
See also:
setAutoScale()

void QwtSlider::setScaleDraw ( QwtScaleDraw scaleDraw  ) 

Set a scale draw.

For changing the labels of the scales, it is necessary to derive from QwtScaleDraw and overload QwtScaleDraw::label().

Parameters:
scaleDraw ScaleDraw object, that has to be created with new and will be deleted in ~QwtSlider or the next call of setScaleDraw().
See also:
scaleDraw()

void QwtAbstractScale::setScaleEngine ( QwtScaleEngine scaleEngine  )  [inherited]

Set a scale engine.

The scale engine is responsible for calculating the scale division, and in case of auto scaling how to align the scale.

scaleEngine has to be created with new and will be deleted in ~QwtAbstractScale or the next call of setScaleEngine.

void QwtAbstractScale::setScaleMaxMajor ( int  ticks  )  [inherited]

Set the maximum number of major tick intervals.

The scale's major ticks are calculated automatically such that the number of major intervals does not exceed ticks. The default value is 5.

Parameters:
ticks maximal number of major ticks.
See also:
QwtAbstractScaleDraw

void QwtAbstractScale::setScaleMaxMinor ( int  ticks  )  [inherited]

Set the maximum number of minor tick intervals.

The scale's minor ticks are calculated automatically such that the number of minor intervals does not exceed ticks. The default value is 3.

Parameters:
ticks 
See also:
QwtAbstractScaleDraw

void QwtSlider::setScalePosition ( ScalePos  scalePos  ) 

Change the scale position (and slider orientation).

Parameters:
scalePos Position of the scale.
A valid combination of scale position and orientation is enforced:
  • if the new scale position is Left or Right, the scale orientation will become Qt::Vertical;
  • if the new scale position is Bottom or Top the scale orientation will become Qt::Horizontal;
  • if the new scale position is QwtSlider::NoScale, the scale orientation will not change.

void QwtSlider::setSpacing ( int  spacing  ) 

Change the spacing between pipe and scale.

A spacing of 0 means, that the backbone of the scale is below the trough.

The default setting is 4 pixels.

Parameters:
spacing Number of pixels
See also:
spacing();

void QwtDoubleRange::setStep ( double  vstep  )  [inherited]

Change the step raster.

Parameters:
vstep new step width
Warning:
The value will not be adjusted to the new step raster.

Reimplemented in QwtCounter.

void QwtAbstractSlider::setTracking ( bool  enable  )  [inherited]

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:

  • the user releases the mouse button and the value has changed or
  • at the end of automatic scrolling.
Tracking is enabled by default.
Parameters:
enable true (enable) or false (disable) tracking.

void QwtAbstractSlider::setUpdateTime ( int  t  )  [inherited]

Specify the update interval for automatic scrolling.

Parameters:
t update interval in milliseconds
See also:
getScrollMode()

void QwtAbstractSlider::setValid ( bool  valid  )  [inline, inherited]

Parameters:
valid true/false
See also:
QwtDblRange::isValid()

Reimplemented from QwtDoubleRange.

void QwtAbstractSlider::setValue ( double  val  )  [virtual, slot, inherited]

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.

Parameters:
val new value
See also:
fitValue()

Reimplemented from QwtDoubleRange.

QSize QwtSlider::sizeHint (  )  const [virtual]

void QwtAbstractSlider::sliderMoved ( double  value  )  [signal, inherited]

This signal is emitted when the user moves the slider with the mouse.

Parameters:
value new value

void QwtAbstractSlider::sliderPressed (  )  [signal, inherited]

This signal is emitted when the user presses the movable part of the slider (start ScrMouse Mode).

void QwtAbstractSlider::sliderReleased (  )  [signal, inherited]

This signal is emitted when the user releases the movable part of the slider.

int QwtSlider::spacing (  )  const

Returns:
Number of pixels between slider and scale
See also:
setSpacing()

double QwtDoubleRange::step (  )  const [inherited]

Returns:
the step size
See also:
setStep(), setRange()

Reimplemented in QwtCounter.

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 (  )  [inherited]

Stop updating if automatic scrolling is active.

void QwtAbstractSlider::timerEvent ( QTimerEvent *  e  )  [protected, virtual, inherited]

Qt timer event

Parameters:
e Timer event

int QwtSlider::transform ( double  value  )  const [protected]

Map and round a value into widget coordinates

Parameters:
value Value

double QwtDoubleRange::value (  )  const [inherited]

Returns the current value.

Reimplemented in QwtCounter.

void QwtSlider::valueChange (  )  [protected, virtual]

Notify change of value.

Reimplemented from QwtAbstractSlider.

void QwtAbstractSlider::valueChanged ( double  value  )  [signal, inherited]

Notify a change of value.

In the default setting (tracking enabled), this signal will be emitted every time the value changes ( see setTracking() ).

Parameters:
value new value

void QwtAbstractSlider::wheelEvent ( QWheelEvent *  e  )  [protected, virtual, inherited]

Wheel Event handler

Parameters:
e Whell event


Generated on Wed Jan 11 15:23:04 2012 for Qwt User's Guide by  doxygen 1.5.9