Qwt User's Guide  5.2.3
Public Types | Public Member Functions | Protected Member Functions
QwtSlider Class Reference

#include <qwt_slider.h>

Inheritance diagram for QwtSlider:
Inheritance graph
[legend]

List of all members.

Public Types

enum  BGSTYLE {
  BgTrough = 0x1,
  BgSlot = 0x2,
  BgBoth = BgTrough | BgSlot
}
enum  ScalePos {
  NoScale,
  LeftScale,
  RightScale,
  TopScale,
  BottomScale
}
- Public Types inherited from QwtAbstractSlider
enum  ScrollMode {
  ScrNone,
  ScrMouse,
  ScrTimer,
  ScrDirect,
  ScrPage
}

Public Member Functions

 QwtSlider (QWidget *parent, Qt::Orientation=Qt::Horizontal, ScalePos=NoScale, BGSTYLE bgStyle=BgTrough)
BGSTYLE bgStyle () const
int borderWidth () const
virtual QSize minimumSizeHint () const
const QwtScaleDrawscaleDraw () const
ScalePos scalePosition () const
void setBgStyle (BGSTYLE)
void setBorderWidth (int bw)
void setMargins (int x, int y)
virtual void setOrientation (Qt::Orientation)
void setScaleDraw (QwtScaleDraw *)
void setScalePosition (ScalePos s)
void setThumbLength (int l)
void setThumbWidth (int w)
virtual QSize sizeHint () const
int thumbLength () const
int thumbWidth () const
- Public Member Functions inherited from QwtAbstractSlider
 QwtAbstractSlider (Qt::Orientation, QWidget *parent=NULL)
virtual ~QwtAbstractSlider ()
bool isReadOnly () const
bool isValid () const
virtual double mass () const
Qt::Orientation orientation () const
virtual void setMass (double val)
void setTracking (bool enable)
void setUpdateTime (int t)
void setValid (bool valid)
void stopMoving ()
- Public Member Functions inherited from QwtDoubleRange
 QwtDoubleRange ()
virtual ~QwtDoubleRange ()
virtual void incPages (int)
double maxValue () const
double minValue () const
int pageSize () const
bool periodic () const
void setPeriodic (bool tf)
void setRange (double vmin, double vmax, double vstep=0.0, int pagesize=1)
void setStep (double)
double step () const
double value () const
- Public Member Functions inherited from QwtAbstractScale
 QwtAbstractScale ()
virtual ~QwtAbstractScale ()
bool autoScale () const
const QwtScaleEnginescaleEngine () const
QwtScaleEnginescaleEngine ()
const QwtScaleMapscaleMap () const
int scaleMaxMajor () const
int scaleMaxMinor () const
void setAutoScale ()
void setScale (double vmin, double vmax, double step=0.0)
void setScale (const QwtDoubleInterval &, double step=0.0)
void setScale (const QwtScaleDiv &s)
void setScaleEngine (QwtScaleEngine *)
void setScaleMaxMajor (int ticks)
void setScaleMaxMinor (int ticks)

Protected Member Functions

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 fontChange (const QFont &oldFont)
virtual void getScrollMode (const QPoint &p, int &scrollMode, int &direction)
virtual double getValue (const QPoint &p)
void layoutSlider (bool update=true)
virtual void paintEvent (QPaintEvent *e)
virtual void rangeChange ()
virtual void resizeEvent (QResizeEvent *e)
virtual void scaleChange ()
QwtScaleDrawscaleDraw ()
virtual void valueChange ()
int xyPosition (double v) const
- Protected Member Functions inherited from QwtAbstractSlider
virtual void keyPressEvent (QKeyEvent *e)
virtual void mouseMoveEvent (QMouseEvent *e)
double mouseOffset () const
virtual void mousePressEvent (QMouseEvent *e)
virtual void mouseReleaseEvent (QMouseEvent *e)
int scrollMode () const
void setMouseOffset (double)
virtual void setPosition (const QPoint &)
virtual void timerEvent (QTimerEvent *e)
virtual void wheelEvent (QWheelEvent *e)
- Protected Member Functions inherited from QwtDoubleRange
double exactPrevValue () const
double exactValue () const
double prevValue () const
virtual void stepChange ()
- Protected Member Functions inherited from QwtAbstractScale
const QwtAbstractScaleDrawabstractScaleDraw () const
QwtAbstractScaleDrawabstractScaleDraw ()
void rescale (double vmin, double vmax, double step=0.0)
void setAbstractScaleDraw (QwtAbstractScaleDraw *)

Additional Inherited Members

- Public Slots inherited from QwtAbstractSlider
virtual void fitValue (double val)
virtual void incValue (int steps)
virtual void setReadOnly (bool)
virtual void setValue (double val)
- Signals inherited from QwtAbstractSlider
void sliderMoved (double value)
void sliderPressed ()
void sliderReleased ()
void valueChanged (double value)

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 Enumeration Documentation

Background style.

See also:
QwtSlider()

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

Constructor & Destructor Documentation

QwtSlider::QwtSlider ( QWidget *  parent,
Qt::Orientation  orientation = Qt::Horizontal,
ScalePos  scalePos = NoScale,
BGSTYLE  bgStyle = BgTrough 
)
explicit

Constructor.

Parameters:
parentparent widget
orientationOrientation of the slider. Can be Qt::Horizontal or Qt::Vertical. Defaults to Qt::Horizontal.
scalePosPosition of the scale. Defaults to QwtSlider::NoScale.
bgStyleBackground 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.

Member Function Documentation

QwtSlider::BGSTYLE QwtSlider::bgStyle ( ) const
Returns:
the background style.
int QwtSlider::borderWidth ( ) const
Returns:
the border width.
void QwtSlider::drawSlider ( QPainter *  painter,
const QRect &  r 
)
protectedvirtual

Draw the slider into the specified rectangle.

Parameters:
painterPainter
rRectangle
void QwtSlider::drawThumb ( QPainter *  painter,
const QRect &  sliderRect,
int  pos 
)
protectedvirtual

Draw the thumb at a position

Parameters:
painterPainter
sliderRectBounding rectangle of the slider
posPosition of the slider thumb
void QwtSlider::getScrollMode ( const QPoint &  p,
int &  scrollMode,
int &  direction 
)
protectedvirtual

Determine scrolling mode and direction.

Parameters:
ppoint
scrollModeScrolling mode
directionDirection

Implements QwtAbstractSlider.

double QwtSlider::getValue ( const QPoint &  pos)
protectedvirtual

Determine the value corresponding to a specified mouse location.

Parameters:
posMouse position

Implements QwtAbstractSlider.

void QwtSlider::layoutSlider ( bool  update_geometry = true)
protected

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

Parameters:
update_geometrynotify the layout system and call update to redraw the scale
QSize QwtSlider::minimumSizeHint ( ) const
virtual

Return a minimum size hint.

Warning:
The return value of QwtSlider::minimumSizeHint() depends on the font and the scale.
void QwtSlider::paintEvent ( QPaintEvent *  event)
protectedvirtual

Qt paint event

Parameters:
eventPaint event
const QwtScaleDraw * QwtSlider::scaleDraw ( ) const
Returns:
the scale draw of the slider
See also:
setScaleDraw()
QwtScaleDraw * QwtSlider::scaleDraw ( )
protected
Returns:
the scale draw of the slider
See also:
setScaleDraw()
void QwtSlider::setBgStyle ( BGSTYLE  st)

Set the background style.

void QwtSlider::setBorderWidth ( int  bd)

Change the slider's border width.

Parameters:
bdborder width
void QwtSlider::setMargins ( int  xMargin,
int  yMargin 
)

Set distances between the widget's border and internals.

Parameters:
xMarginHorizontal margin
yMarginVertical margin
void QwtSlider::setOrientation ( Qt::Orientation  o)
virtual

Set the orientation.

Parameters:
oOrientation. 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 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().
void QwtSlider::setScalePosition ( ScalePos  s)

Change the scale position (and slider orientation).

Parameters:
sPosition 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::setThumbLength ( int  thumbLength)

Set the slider's thumb length.

Parameters:
thumbLengthnew length
void QwtSlider::setThumbWidth ( int  w)

Change the width of the thumb.

Parameters:
wnew width
QSize QwtSlider::sizeHint ( ) const
virtual
int QwtSlider::thumbLength ( ) const
Returns:
the thumb length.
int QwtSlider::thumbWidth ( ) const
Returns:
the thumb width.
int QwtSlider::xyPosition ( double  value) const
protected

Find the x/y position for a given value v

Parameters:
valueValue