QwtKnob Class Reference

The Knob Widget. More...

`#include <qwt_knob.h>`

Inheritance diagram for QwtKnob:
[legend]

## Public Types

enum | KnobStyle { Flat, Raised, Sunken, Styled }
| Style of the knob surface. More...
enum | MarkerStyle { NoMarker = -1, Tick, Triangle, Dot, Nub, Notch }
| Marker type. More...

## Public Member Functions

| QwtKnob (QWidget *parent=NULL)
| Constructor. More...
virtual | ~QwtKnob ()
| Destructor.
void | setAlignment (Qt::Alignment)
| Set the alignment of the knob. More...
Qt::Alignment | alignment () const
void | setKnobWidth (int)
| Change the knob's width. More...
int | knobWidth () const
| Return the width of the knob.
void | setNumTurns (int)
| Set the number of turns. More...
int | numTurns () const
void | setTotalAngle (double angle)
| Set the total angle by which the knob can be turned. More...
double | totalAngle () const
void | setKnobStyle (KnobStyle)
| Set the knob type. More...
KnobStyle | knobStyle () const
void | setBorderWidth (int bw)
| Set the knob's border width. More...
int | borderWidth () const
| Return the border width.
void | setMarkerStyle (MarkerStyle)
| Set the marker type of the knob. More...
MarkerStyle | markerStyle () const
void | setMarkerSize (int)
| Set the size of the marker. More...
int | markerSize () const
virtual QSize | sizeHint () const
virtual QSize | minimumSizeHint () const
void | setScaleDraw (QwtRoundScaleDraw *)
const QwtRoundScaleDraw * | scaleDraw () const
QwtRoundScaleDraw * | scaleDraw ()
QRect | knobRect () 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 void | paintEvent (QPaintEvent *)
virtual void | changeEvent (QEvent *)
virtual void | drawKnob (QPainter *, const QRectF &) const
| Draw the knob. More...
virtual void | drawFocusIndicator (QPainter *) const
virtual void | drawMarker (QPainter *, const QRectF &, double arc) const
| Draw the marker at the knob's front. More...
virtual double | scrolledTo (const QPoint &) const
| Determine the value for a new position of the mouse. More...
virtual bool | isScrollPosition (const QPoint &) const
| Determine what to do when the user presses a mouse button. More...
Protected Member Functions inherited from QwtAbstractSlider
virtual void | mousePressEvent (QMouseEvent *)
virtual void | mouseReleaseEvent (QMouseEvent *)
virtual void | mouseMoveEvent (QMouseEvent *)
virtual void | keyPressEvent (QKeyEvent *)
virtual void | wheelEvent (QWheelEvent *)
void | incrementValue (int numSteps)
virtual void | scaleChange ()
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 Knob Widget.

The QwtKnob widget imitates look and behavior of a volume knob on a radio. It looks similar to QDial - not to QwtDial.

The value range of a knob might be divided into several turns.

The layout of the knob depends on the knobWidth().

- width > 0 The diameter of the knob is fixed and the knob is aligned according to the alignment() flags inside of the contentsRect().
- width <= 0 The knob is extended to the minimum of width/height of the contentsRect() and aligned in the other direction according to alignment().

Setting a fixed knobWidth() is helpful to align several knobs with different scale labels.

## Member Enumeration Documentation

enum QwtKnob::KnobStyle

Style of the knob surface.

Depending on the KnobStyle the surface of the knob is filled from the brushes of the widget palette().

See also
  setKnobStyle(), knobStyle()

Enumerator
Flat | Fill the knob with a brush from QPalette::Button.
Raised | Build a gradient from QPalette::Midlight and QPalette::Button.
Sunken | Build a gradient from QPalette::Midlight, QPalette::Button and QPalette::Midlight
Styled | Build a radial gradient from QPalette::Button like it is used for QDial in various Qt styles.

enum QwtKnob::MarkerStyle

Marker type.

The marker indicates the current value on the knob The default setting is a Notch marker.

See also
  setMarkerStyle(), setMarkerSize()

Enumerator
NoMarker | Don't paint any marker.
Tick | Paint a single tick in QPalette::ButtonText color.
Triangle | Paint a triangle in QPalette::ButtonText color.
Dot | Paint a circle in QPalette::ButtonText color.
Nub | Draw a raised ellipse with a gradient build from QPalette::Light and QPalette::Mid
Notch | Draw a sunken ellipse with a gradient build from QPalette::Light and QPalette::Mid

## Constructor & Destructor Documentation

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

explicit

Constructor.

Construct a knob with an angle of 270°. The style is QwtKnob::Raised and the marker style is QwtKnob::Notch. The width of the knob is set to 50 pixels.

Parameters

  parent | Parent widget

See also
  setTotalAngle()

## Member Function Documentation

Qt::Alignment QwtKnob::alignment | ( |  | ) | const

Returns
  Alignment of the knob inside of contentsRect()

See also
  setAlignment(), knobWidth(), knobRect()

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

protected virtual

Handle QEvent::StyleChange and QEvent::FontChange;

Parameters

  event | Change event

void QwtKnob::drawFocusIndicator | ( | QPainter * | painter | ) | const

protected virtual

Draw the focus indicator

Parameters

  painter | Painter

void QwtKnob::drawKnob | ( | QPainter * | painter,
|  | const QRectF & | knobRect
| ) |  | const

protected virtual

Draw the knob.

Parameters

  painter | painter
  knobRect | Bounding rectangle of the knob (without scale)

void QwtKnob::drawMarker | ( | QPainter * | painter,
|  | const QRectF & | rect,
|  | double | angle
| ) |  | const

protected virtual

Draw the marker at the knob's front.

Parameters

  painter | Painter
  rect | Bounding rectangle of the knob without scale
  angle | Angle of the marker in degrees ( clockwise, 0 at the 12 o'clock position )

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

protected virtual

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

Parameters

  pos | Mouse position

Return values

  True,when | pos is inside the circle of the knob.

See also
  scrolledTo()

Implements QwtAbstractSlider.

QRect QwtKnob::knobRect | ( |  | ) | const

Calculate the bounding rectangle of the knob without the scale

Returns
  Bounding rectangle of the knob

See also
  knobWidth(), alignment(), QWidget::contentsRect()

QwtKnob::KnobStyle QwtKnob::knobStyle | ( |  | ) | const

Returns
  Marker type of the knob

See also
  setKnobStyle(), setBorderWidth()

int QwtKnob::markerSize | ( |  | ) | const

Returns
  Marker size

See also
  setMarkerSize()

QwtKnob::MarkerStyle QwtKnob::markerStyle | ( |  | ) | const

Returns
  Marker type of the knob

See also
  setMarkerStyle(), setMarkerSize()

QSize QwtKnob::minimumSizeHint | ( |  | ) | const

virtual

Returns
  Minimum size hint

See also
  sizeHint()

int QwtKnob::numTurns | ( |  | ) | const

Returns
  Number of turns.

When the total angle is below 360° numTurns() is ceiled to 1.

See also
  setNumTurns(), setTotalAngle(), totalAngle()

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

protected virtual

Repaint the knob

Parameters

  event | Paint event

const QwtRoundScaleDraw * QwtKnob::scaleDraw | ( |  | ) | const

Returns
  the scale draw of the knob

See also
  setScaleDraw()

QwtRoundScaleDraw * QwtKnob::scaleDraw | ( |  | ) |

Returns
  the scale draw of the knob

See also
  setScaleDraw()

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

protected virtual

Determine the value for a new position of the mouse.

Parameters

  pos | Mouse position

Returns
  Value for the mouse position

See also
  isScrollPosition()

Implements QwtAbstractSlider.

void QwtKnob::setAlignment | ( | Qt::Alignment | alignment | ) |

Set the alignment of the knob.

Similar to a QLabel::alignment() the flags decide how to align the knob inside of contentsRect().

The default setting is Qt::AlignCenter

Parameters

  alignment | Or'd alignment flags

See also
  alignment(), setKnobWidth(), knobRect()

void QwtKnob::setBorderWidth | ( | int | borderWidth | ) |

Set the knob's border width.

Parameters

  borderWidth | new border width

void QwtKnob::setKnobStyle | ( | KnobStyle | knobStyle | ) |

Set the knob type.

Parameters

  knobStyle | Knob type

See also
  knobStyle(), setBorderWidth()

void QwtKnob::setKnobWidth | ( | int | width | ) |

Change the knob's width.

Setting a fixed value for the diameter of the knob is helpful for aligning several knobs in a row.

Parameters

  width | New width

See also
  knobWidth(), setAlignment()

Note
  Modifies the sizePolicy()

void QwtKnob::setMarkerSize | ( | int | size | ) |

Set the size of the marker.

When setting a size <= 0 the marker will automatically scaled to 40% of the radius of the knob.

See also
  markerSize(), markerStyle()

void QwtKnob::setMarkerStyle | ( | MarkerStyle | markerStyle | ) |

Set the marker type of the knob.

Parameters

  markerStyle | Marker type

See also
  markerStyle(), setMarkerSize()

void QwtKnob::setNumTurns | ( | int | numTurns | ) |

Set the number of turns.

When numTurns > 1 the knob can be turned several times around its axis

- otherwise the total angle is floored to 360°.

See also
  numTurns(), totalAngle(), setTotalAngle()

void QwtKnob::setScaleDraw | ( | QwtRoundScaleDraw * | scaleDraw | ) |

Change the scale draw of the knob

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

See also
  scaleDraw()

void QwtKnob::setTotalAngle | ( | double | angle | ) |

Set the total angle by which the knob can be turned.

Parameters

  angle | Angle in degrees.

The angle has to be between [10, 360] degrees. Angles above 360 ( so that the knob can be turned several times around its axis ) have to be set using setNumTurns().

The default angle is 270 degrees.

See also
  totalAngle(), setNumTurns()

QSize QwtKnob::sizeHint | ( |  | ) | const

virtual

Returns
  sizeHint()

double QwtKnob::totalAngle | ( |  | ) | const

Returns
  the total angle

See also
  setTotalAngle(), setNumTurns(), numTurns()