# QwtSlider Class Reference

Inheritance diagram for QwtSlider:

[legend]
Collaboration diagram for QwtSlider:

[legend]
List of all members.

## 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.

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

Definition at line 34 of file qwt_slider.h.

## Public Types

enum | ScalePos { NoScale, LeftScale, RightScale, TopScale, BottomScale, NoScale, LeftScale, RightScale, TopScale, BottomScale }
enum | BGSTYLE { BgTrough = 0x1, BgSlot = 0x2, BgBoth = BgTrough | BgSlot }

## Public Member Functions

| QwtSlider (QWidget *parent, Qt::Orientation=Qt::Horizontal, ScalePos=NoScale, BGSTYLE bgStyle=BgTrough)
virtual | ~QwtSlider ()
virtual void | setOrientation (Qt::Orientation)
void | setBgStyle (BGSTYLE)
BGSTYLE | bgStyle () const
void | setScalePosition (ScalePos s)
ScalePos | scalePosition () const
int | thumbLength () const
int | thumbWidth () const
int | borderWidth () const
void | setThumbLength (int l)
void | setThumbWidth (int w)
void | setBorderWidth (int bw)
void | setMargins (int x, int y)
virtual QSize | sizeHint () const
virtual QSize | minimumSizeHint () const
void | setScaleDraw (QwtScaleDraw *)
const QwtScaleDraw * | scaleDraw () const

## Protected Member Functions

virtual double | getValue (const QPoint &p)
virtual void | getScrollMode (const QPoint &p, int &scrollMode, int &direction)
void | draw (QPainter *p, const QRect &update_rect)
virtual void | drawSlider (QPainter *p, const QRect &r)
virtual void | drawThumb (QPainter *p, const QRect &, int pos)
virtual void | resizeEvent (QResizeEvent *e)
virtual void | paintEvent (QPaintEvent *e)
virtual void | valueChange ()
virtual void | rangeChange ()
virtual void | scaleChange ()
virtual void | fontChange (const QFont &oldFont)
void | layoutSlider (bool update=true)
int | xyPosition (double v) const
QwtScaleDraw * | scaleDraw ()

## Member Enumeration Documentation

enum QwtSlider::ScalePos

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::QwtSlider

Definition at line 56 of file qwt_slider.h.

enum QwtSlider::BGSTYLE

Background style.

See also:
  QwtSlider::QwtSlider

Definition at line 70 of file qwt_slider.h.

## Constructor & Destructor Documentation

QwtSlider::QwtSlider | ( | QWidget * | parent,
|  | Qt::Orientation | orientation = `Qt::Horizontal`,
|  | ScalePos | scalePos = `NoScale`,
|  | BGSTYLE | bgStyle = `BgTrough` |
| ) |  |  | `[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::BgTrough draws the slider button in a trough, QwtSlider::BgSlot draws a slot underneath the button. An or-combination of both may also be used. The default is QwtSlider::BgTrough.

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.

Definition at line 64 of file qwt_slider.cpp.

## Member Function Documentation

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.

Definition at line 174 of file qwt_slider.cpp.

References layoutSlider(), QwtAbstractSlider::orientation(), and QwtAbstractSlider::setOrientation().

Referenced by setScalePosition().

void QwtSlider::setBgStyle | ( | BGSTYLE | st | ) |

Set the background style.

Definition at line 784 of file qwt_slider.cpp.

References layoutSlider().

QwtSlider::BGSTYLE QwtSlider::bgStyle | ( |  | ) | const

Returns:
  the background style.

Definition at line 793 of file qwt_slider.cpp.

void QwtSlider::setScalePosition | ( | ScalePos | s | ) |

Change the scale position (and slider orientation).

Parameters:

  | s | 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.

Definition at line 224 of file qwt_slider.cpp.

References layoutSlider(), scaleDraw(), QwtScaleDraw::setAlignment(), and setOrientation().

QwtSlider::ScalePos QwtSlider::scalePosition | ( |  | ) | const

Return the scale position.

Definition at line 267 of file qwt_slider.cpp.

int QwtSlider::thumbLength | ( |  | ) | const

Returns:
  the thumb length.

Definition at line 801 of file qwt_slider.cpp.

Referenced by getScrollMode().

int QwtSlider::thumbWidth | ( |  | ) | const

Returns:
  the thumb width.

Definition at line 809 of file qwt_slider.cpp.

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

Returns:
  the border width.

Definition at line 817 of file qwt_slider.cpp.

void QwtSlider::setThumbLength | ( | int | thumbLength | ) |

Set the slider's thumb length.

Parameters:

  | thumbLength | new length

Definition at line 292 of file qwt_slider.cpp.

References layoutSlider().

void QwtSlider::setThumbWidth | ( | int | w | ) |

Change the width of the thumb.

Parameters:

  | w | new width

Definition at line 308 of file qwt_slider.cpp.

References layoutSlider().

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

Change the slider's border width.

Parameters:

  | bd | border width

Definition at line 276 of file qwt_slider.cpp.

References layoutSlider().

void QwtSlider::setMargins | ( | int | xMargin,
|  | int | yMargin |
| ) |  |  |

Set distances between the widget's border and internals.

Parameters:

  | xMargin | Horizontal margin
  | yMargin | Vertical margin

Definition at line 766 of file qwt_slider.cpp.

References layoutSlider().

QSize QwtSlider::sizeHint | ( |  | ) | const`[virtual]`

Returns:
  QwtSlider::minimumSizeHint()

Definition at line 825 of file qwt_slider.cpp.

References minimumSizeHint().

QSize QwtSlider::minimumSizeHint | ( |  | ) | const`[virtual]`

Return a minimum size hint.

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

Definition at line 835 of file qwt_slider.cpp.

References QwtScaleDraw::extent(), QwtScaleDraw::getBorderDistHint(), QwtScaleDraw::minLength(), QwtAbstractSlider::orientation(), and scaleDraw().

Referenced by sizeHint().

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

Definition at line 331 of file qwt_slider.cpp.

References QwtScaleDraw::alignment(), layoutSlider(), scaleDraw(), QwtAbstractScale::setAbstractScaleDraw(), and QwtScaleDraw::setAlignment().

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

Returns:
  the scale draw of the slider

See also:
  setScaleDraw()

Definition at line 348 of file qwt_slider.cpp.

References QwtAbstractScale::abstractScaleDraw().

Referenced by draw(), getScrollMode(), layoutSlider(), minimumSizeHint(), setScaleDraw(), and setScalePosition().

double QwtSlider::getValue | ( | const QPoint & | p | ) | `[protected, virtual]`

Determine the value corresponding to a specified mouse location.

Implements QwtAbstractSlider.

Definition at line 517 of file qwt_slider.cpp.

References QwtAbstractSlider::orientation().

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

Determine scrolling mode and direction.

Parameters:

  | p | point
  | scrollMode | Scrolling mode
  | direction | Direction

Implements QwtAbstractSlider.

Definition at line 530 of file qwt_slider.cpp.

References QwtAbstractSlider::orientation(), scaleDraw(), thumbLength(), QwtDoubleRange::value(), and xyPosition().

void QwtSlider::draw | ( | QPainter * | p,
|  | const QRect & | update_rect |
| ) |  |  | `[protected]`

Draw the QwtSlider.

Definition at line 575 of file qwt_slider.cpp.

References QwtAbstractScaleDraw::draw(), QwtPainter::drawFocusRect(), drawSlider(), and scaleDraw().

Referenced by paintEvent().

void QwtSlider::drawSlider | ( | QPainter * | p,
|  | const QRect & | r |
| ) |  |  | `[protected, virtual]`

Draw the slider into the specified rectangle.

Definition at line 377 of file qwt_slider.cpp.

References drawThumb(), QwtAbstractSlider::isValid(), QwtAbstractSlider::orientation(), QwtDoubleRange::value(), and xyPosition().

Referenced by draw().

void QwtSlider::drawThumb | ( | QPainter * | p,
|  | const QRect & | ,
|  | int | pos |
| ) |  |  | `[protected, virtual]`

Draw the thumb at a position.

Definition at line 453 of file qwt_slider.cpp.

References QwtAbstractSlider::orientation().

Referenced by drawSlider().

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

Qt resize event.

Definition at line 593 of file qwt_slider.cpp.

References layoutSlider().

void QwtSlider::paintEvent | ( | QPaintEvent * | e | ) | `[protected, virtual]`

Qt paint event.

Definition at line 559 of file qwt_slider.cpp.

References draw().

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

Notify change of value.

Reimplemented from QwtAbstractSlider.

Definition at line 742 of file qwt_slider.cpp.

References QwtAbstractSlider::valueChange().

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

Notify change of range.

Reimplemented from QwtDoubleRange.

Definition at line 750 of file qwt_slider.cpp.

References QwtAbstractScale::autoScale(), layoutSlider(), QwtDoubleRange::maxValue(), QwtDoubleRange::minValue(), QwtDoubleRange::rangeChange(), and QwtAbstractScale::rescale().

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

Notify changed scale.

Reimplemented from QwtAbstractScale.

Definition at line 363 of file qwt_slider.cpp.

References layoutSlider().

void QwtSlider::fontChange | ( | const QFont & | oldFont | ) | `[protected, virtual]`

Notify change in font.

Definition at line 370 of file qwt_slider.cpp.

References layoutSlider().

void QwtSlider::layoutSlider | ( | bool | update_geometry = `true` | ) | `[protected]`

Recalculate the slider's geometry and layout based on the current rect and fonts.

Parameters:

  | update_geometry | notify the layout system and call update to redraw the scale

Definition at line 604 of file qwt_slider.cpp.

References QwtScaleDraw::getBorderDistHint(), QwtScaleDraw::move(), QwtAbstractSlider::orientation(), scaleDraw(), and QwtScaleDraw::setLength().

Referenced by fontChange(), rangeChange(), resizeEvent(), scaleChange(), setBgStyle(), setBorderWidth(), setMargins(), setOrientation(), setScaleDraw(), setScalePosition(), setThumbLength(), and setThumbWidth().

int QwtSlider::xyPosition | ( | double | v | ) | const`[protected]`

Find the x/y position for a given value v.

Definition at line 511 of file qwt_slider.cpp.

Referenced by drawSlider(), and getScrollMode().

QwtScaleDraw * QwtSlider::scaleDraw | ( |  | ) | `[protected]`

Returns:
  the scale draw of the slider

See also:
  setScaleDraw()

Definition at line 357 of file qwt_slider.cpp.

References QwtAbstractScale::abstractScaleDraw().