Qwt User's Guide
QwtSlider Class Reference

The Slider Widget. More...

#include <qwt_slider.h>

Inheritance diagram for QwtSlider:

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.
Qt::Orientation orientation () const
void setScalePosition (ScalePosition)
 Change the position of the scale.
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.
QSize handleSize () const
void setBorderWidth (int bw)
 Change the slider's border width.
int borderWidth () const
void setSpacing (int)
 Change the spacing between trough and scale.
int spacing () const
virtual QSize sizeHint () const
virtual QSize minimumSizeHint () const
void setScaleDraw (QwtScaleDraw *)
 Set a scale draw.
const QwtScaleDrawscaleDraw () const
void setUpdateInterval (int)
 Specify the update interval for automatic scrolling.
int updateInterval () const

Protected Member Functions

virtual double scrolledTo (const QPoint &) const
 Determine the value for a new position of the slider handle.
virtual bool isScrollPosition (const QPoint &) const
 Determine what to do when the user presses a mouse button.
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

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.

sliders.png

Member Enumeration Documentation

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:
parentParent 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:
parentParent widget
orientationOrientation of the slider.

Member Function Documentation

int QwtSlider::borderWidth ( ) const
Returns:
the border width.
See also:
setBorderWidth()
void QwtSlider::changeEvent ( QEvent *  event) [protected, virtual]

Handles QEvent::StyleChange and QEvent::FontChange events

Parameters:
eventChange event
void QwtSlider::drawHandle ( QPainter *  painter,
const QRect &  handleRect,
int  pos 
) const [protected, virtual]

Draw the thumb at a position

Parameters:
painterPainter
handleRectBounding rectangle of the handle
posPosition of the handle marker in widget coordinates
void QwtSlider::drawSlider ( QPainter *  painter,
const QRect &  sliderRect 
) const [protected, virtual]

Draw the slider into the specified rectangle.

Parameters:
painterPainter
sliderRectBounding 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 [protected, virtual]

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

Parameters:
posMouse position
Return values:
True,whenhandleRect() contains pos
See also:
scrolledTo()

Implements QwtAbstractSlider.

QSize QwtSlider::minimumSizeHint ( ) const [virtual]
Returns:
Minimum size hint
See also:
sizeHint()
void QwtSlider::mousePressEvent ( QMouseEvent *  event) [protected, virtual]

Mouse press event handler

Parameters:
eventMouse event

Reimplemented from QwtAbstractSlider.

void QwtSlider::mouseReleaseEvent ( QMouseEvent *  event) [protected, virtual]

Mouse release event handler

Parameters:
eventMouse event

Reimplemented from QwtAbstractSlider.

Qt::Orientation QwtSlider::orientation ( ) const
Returns:
Orientation
See also:
setOrientation()
void QwtSlider::paintEvent ( QPaintEvent *  event) [protected, virtual]

Qt paint event handler

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

Qt resize event handler

Parameters:
eventResize event
Returns:
the scale draw of the slider
See also:
setScaleDraw()
Returns:
Position of the scale
See also:
setScalePosition()
double QwtSlider::scrolledTo ( const QPoint &  pos) const [protected, virtual]

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

Parameters:
posMouse 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:
widthBorder 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:
onWhen 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:
sizeNew size
See also:
handleSize()
void QwtSlider::setOrientation ( Qt::Orientation  orientation)

Set the orientation.

Parameters:
orientationAllowed 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:
scaleDrawScaleDraw 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:
scalePositionPosition 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:
spacingNumber 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:
onWhen 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:
intervalUpdate interval in milliseconds
See also:
setUpdateInterval()
QSize QwtSlider::sizeHint ( ) const [virtual]
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) [protected, virtual]

Timer event handler

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

Parameters:
eventMouse event
Returns:
Update interval in milliseconds for automatic scrolling
See also:
setUpdateInterval()

List of all members.

 All Classes Functions Variables Typedefs Enumerations Enumerator