Qwt User's Guide: QwtSlider Class Reference

Qwt User's Guide 6.1.2

- Main Page
- Related Pages
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Public Member Functions | Protected Member Functions | List of all members
QwtSlider Class Reference

The Slider Widget. More...

`#include <qwt_slider.h>`

Inheritance diagram for QwtSlider:
[legend]

## Public Types

enum | ScalePosition { NoScale, LeadingScale, TrailingScale }

## Public Member Functions

| QwtSlider (QWidget *parent=NULL)
| QwtSlider (Qt::Orientation, QWidget *parent=NULL)
virtual | ~QwtSlider ()
| Destructor.
void | setOrientation (Qt::Orientation)
| Set the orientation. More...
Qt::Orientation | orientation () const
void | setScalePosition (ScalePosition)
| Change the position of the scale. More...
ScalePosition | scalePosition () const
void | setTrough (bool)
bool | hasTrough () const
void | setGroove (bool)
bool | hasGroove () const
void | setHandleSize (const QSize &)
| Set the slider's handle size. More...
QSize | handleSize () const
void | setBorderWidth (int bw)
| Change the slider's border width. More...
int | borderWidth () const
void | setSpacing (int)
| Change the spacing between trough and scale. More...
int | spacing () const
virtual QSize | sizeHint () const
virtual QSize | minimumSizeHint () const
void | setScaleDraw (QwtScaleDraw *)
| Set a scale draw. More...
const QwtScaleDraw * | scaleDraw () const
void | setUpdateInterval (int)
| Specify the update interval for automatic scrolling. More...
int | updateInterval () const
Public Member Functions inherited from QwtAbstractSlider
| QwtAbstractSlider (QWidget *parent=NULL)
| Constructor. More...
virtual | ~QwtAbstractSlider ()
| Destructor.
void | setValid (bool)
bool | isValid () const
double | value () const
| Returns the current value.
void | setWrapping (bool)
bool | wrapping () const
void | setTotalSteps (uint)
| Set the number of steps. More...
uint | totalSteps () const
void | setSingleSteps (uint)
| Set the number of steps for a single increment. More...
uint | singleSteps () const
void | setPageSteps (uint)
| Set the number of steps for a page increment. More...
uint | pageSteps () const
void | setStepAlignment (bool)
| Enable step alignment. More...
bool | stepAlignment () const
void | setTracking (bool)
| Enables or disables tracking. More...
bool | isTracking () const
void | setReadOnly (bool)
bool | isReadOnly () const
void | setInvertedControls (bool)
bool | invertedControls () const
Public Member Functions inherited from QwtAbstractScale
| QwtAbstractScale (QWidget *parent=NULL)
virtual | ~QwtAbstractScale ()
| Destructor.
void | setScale (double lowerBound, double upperBound)
| Specify a scale. More...
void | setScale (const QwtInterval &)
| Specify a scale. More...
void | setScale (const QwtScaleDiv &)
| Specify a scale. More...
const QwtScaleDiv & | scaleDiv () const
void | setLowerBound (double value)
double | lowerBound () const
void | setUpperBound (double value)
double | upperBound () const
void | setScaleStepSize (double stepSize)
| Set the step size used for calculating a scale division. More...
double | scaleStepSize () const
void | setScaleMaxMajor (int ticks)
| Set the maximum number of major tick intervals. More...
int | scaleMaxMinor () const
void | setScaleMaxMinor (int ticks)
| Set the maximum number of minor tick intervals. More...
int | scaleMaxMajor () const
void | setScaleEngine (QwtScaleEngine *)
| Set a scale engine. More...
const QwtScaleEngine * | scaleEngine () const
QwtScaleEngine * | scaleEngine ()
int | transform (double) const
double | invTransform (int) const
bool | isInverted () const
double | minimum () const
double | maximum () const
const QwtScaleMap & | scaleMap () const

## Protected Member Functions

virtual double | scrolledTo (const QPoint &) const
| Determine the value for a new position of the slider handle. More...
virtual bool | isScrollPosition (const QPoint &) const
| Determine what to do when the user presses a mouse button. More...
virtual void | drawSlider (QPainter *, const QRect &) const
virtual void | drawHandle (QPainter *, const QRect &, int pos) const
virtual void | mousePressEvent (QMouseEvent *)
virtual void | mouseReleaseEvent (QMouseEvent *)
virtual void | resizeEvent (QResizeEvent *)
virtual void | paintEvent (QPaintEvent *)
virtual void | changeEvent (QEvent *)
virtual void | timerEvent (QTimerEvent *)
virtual void | scaleChange ()
| Notify changed scale.
QRect | sliderRect () const
QRect | handleRect () const
Protected Member Functions inherited from QwtAbstractSlider
virtual void | mouseMoveEvent (QMouseEvent *)
virtual void | keyPressEvent (QKeyEvent *)
virtual void | wheelEvent (QWheelEvent *)
void | incrementValue (int numSteps)
virtual void | sliderChange ()
| Calling update()
double | incrementedValue (double value, int stepCount) const
Protected Member Functions inherited from QwtAbstractScale
void | rescale (double lowerBound, double upperBound, double stepSize)
void | setAbstractScaleDraw (QwtAbstractScaleDraw *)
| Set a scale draw. More...
const QwtAbstractScaleDraw * | abstractScaleDraw () const
QwtAbstractScaleDraw * | abstractScaleDraw ()

## Additional Inherited Members

Public Slots inherited from QwtAbstractSlider
void | setValue (double val)
Signals inherited from QwtAbstractSlider
void | valueChanged (double value)
| Notify a change of value. More...
void | sliderPressed ()
void | sliderReleased ()
void | sliderMoved (double value)

## Detailed Description

The Slider Widget.

QwtSlider is a slider widget which operates on an interval of type double. Its position is related to a scale showing the current value.

The slider can be customized by having a through, a groove - or both.

## Member Enumeration Documentation

enum QwtSlider::ScalePosition

Position of the scale

See Also
  QwtSlider(), setScalePosition(), setOrientation()

Enumerator
NoScale | The slider has no scale.
LeadingScale | The scale is right of a vertical or below a horizontal slider.
TrailingScale | The scale is left of a vertical or above a horizontal slider.

## Constructor & Destructor Documentation

QwtSlider::QwtSlider | ( | QWidget * | parent = `NULL` | ) |

explicit

Construct vertical slider in QwtSlider::Trough style with a scale to the left.

The scale is initialized to [0.0, 100.0] and the value set to 0.0.

Parameters

  parent | Parent widget

See Also
  setOrientation(), setScalePosition(), setBackgroundStyle()

QwtSlider::QwtSlider | ( | Qt::Orientation | orientation,
|  | QWidget * | parent = `NULL`
| ) |  |

explicit

Construct a slider in QwtSlider::Trough style

When orientation is Qt::Vertical the scale will be aligned to the left - otherwise at the the top of the slider.

The scale is initialized to [0.0, 100.0] and the value set to 0.0.

Parameters

  parent | Parent widget
  orientation | Orientation of the slider.

## Member Function Documentation

int QwtSlider::borderWidth | ( |  | ) | const

Returns
  the border width.

See Also
  setBorderWidth()

void QwtSlider::changeEvent | ( | QEvent * | event | ) |

protectedvirtual

Handles QEvent::StyleChange and QEvent::FontChange events

Parameters

  event | Change event

void QwtSlider::drawHandle | ( | QPainter * | painter,
|  | const QRect & | handleRect,
|  | int | pos
| ) |  | const

protectedvirtual

Draw the thumb at a position

Parameters

  painter | Painter
  handleRect | Bounding rectangle of the handle
  pos | Position of the handle marker in widget coordinates

void QwtSlider::drawSlider | ( | QPainter * | painter,
|  | const QRect & | sliderRect
| ) |  | const

protectedvirtual

Draw the slider into the specified rectangle.

Parameters

  painter | Painter
  sliderRect | Bounding rectangle of the slider

QRect QwtSlider::handleRect | ( |  | ) | const

protected

Returns
  Bounding rectangle of the slider handle

QSize QwtSlider::handleSize | ( |  | ) | const

Returns
  Size of the handle.

See Also
  setHandleSize()

bool QwtSlider::hasGroove | ( |  | ) | const

Returns
  True, when the groove is visisble

See Also
  setGroove(), hasTrough()

bool QwtSlider::hasTrough | ( |  | ) | const

Returns
  True, when the trough is visisble

See Also
  setTrough(), hasGroove()

bool QwtSlider::isScrollPosition | ( | const QPoint & | pos | ) | const

protectedvirtual

Determine what to do when the user presses a mouse button.

Parameters

  pos | Mouse position

Return values

  True,when | handleRect() contains pos

See Also
  scrolledTo()

Implements QwtAbstractSlider.

QSize QwtSlider::minimumSizeHint | ( |  | ) | const

virtual

Returns
  Minimum size hint

See Also
  sizeHint()

void QwtSlider::mousePressEvent | ( | QMouseEvent * | event | ) |

protectedvirtual

Mouse press event handler

Parameters

  event | Mouse event

Reimplemented from QwtAbstractSlider.

void QwtSlider::mouseReleaseEvent | ( | QMouseEvent * | event | ) |

protectedvirtual

Mouse release event handler

Parameters

  event | Mouse event

Reimplemented from QwtAbstractSlider.

Qt::Orientation QwtSlider::orientation | ( |  | ) | const

Returns
  Orientation

See Also
  setOrientation()

void QwtSlider::paintEvent | ( | QPaintEvent * | event | ) |

protectedvirtual

Qt paint event handler

Parameters

  event | Paint event

void QwtSlider::resizeEvent | ( | QResizeEvent * | event | ) |

protectedvirtual

Qt resize event handler

Parameters

  event | Resize event

const QwtScaleDraw * QwtSlider::scaleDraw | ( |  | ) | const

Returns
  the scale draw of the slider

See Also
  setScaleDraw()

QwtSlider::ScalePosition QwtSlider::scalePosition | ( |  | ) | const

Returns
  Position of the scale

See Also
  setScalePosition()

double QwtSlider::scrolledTo | ( | const QPoint & | pos | ) | const

protectedvirtual

Determine the value for a new position of the slider handle.

Parameters

  pos | Mouse position

Returns
  Value for the mouse position

See Also
  isScrollPosition()

Implements QwtAbstractSlider.

void QwtSlider::setBorderWidth | ( | int | width | ) |

Change the slider's border width.

The border width is used for drawing the slider handle and the trough.

Parameters

  width | Border width

See Also
  borderWidth()

void QwtSlider::setGroove | ( | bool | on | ) |

En/Disable the groove

The slider can be cutomized by showing a groove for the handle.

Parameters

  on | When true, the groove is visible

See Also
  hasGroove(), setThrough()

void QwtSlider::setHandleSize | ( | const QSize & | size | ) |

Set the slider's handle size.

When the size is empty the slider handle will be painted with a default size depending on its orientation() and backgroundStyle().

Parameters

  size | New size

See Also
  handleSize()

void QwtSlider::setOrientation | ( | Qt::Orientation | orientation | ) |

Set the orientation.

Parameters

  orientation | Allowed values are Qt::Horizontal and Qt::Vertical.

See Also
  orientation(), scalePosition()

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 QwtSlider::setScalePosition | ( | ScalePosition | scalePosition | ) |

Change the position of the scale.

Parameters

  scalePosition | Position of the scale.

See Also
  ScalePosition, scalePosition()

void QwtSlider::setSpacing | ( | int | spacing | ) |

Change the spacing between trough and scale.

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

The default setting is 4 pixels.

Parameters

  spacing | Number of pixels

See Also
  spacing();

void QwtSlider::setTrough | ( | bool | on | ) |

En/Disable the trough

The slider can be cutomized by showing a trough for the handle.

Parameters

  on | When true, the groove is visible

See Also
  hasTrough(), setGroove()

void QwtSlider::setUpdateInterval | ( | int | interval | ) |

Specify the update interval for automatic scrolling.

The minimal accepted value is 50 ms.

Parameters

  interval | Update interval in milliseconds

See Also
  setUpdateInterval()

QSize QwtSlider::sizeHint | ( |  | ) | const

virtual

Returns
  minimumSizeHint()

QRect QwtSlider::sliderRect | ( |  | ) | const

protected

Returns
  Bounding rectangle of the slider - without the scale

int QwtSlider::spacing | ( |  | ) | const

Returns
  Number of pixels between slider and scale

See Also
  setSpacing()

void QwtSlider::timerEvent | ( | QTimerEvent * | event | ) |

protectedvirtual

Timer event handler

Handles the timer, when the mouse stays pressed inside the sliderRect().

Parameters

  event | Mouse event

int QwtSlider::updateInterval | ( |  | ) | const

Returns
  Update interval in milliseconds for automatic scrolling

See Also
  setUpdateInterval()