QWT 7.0.1
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | Properties | List of all members
QwtKnob Class Reference

The Knob Widget. More...

#include <qwt_knob.h>

Inheritance diagram for QwtKnob:
QwtAbstractSlider QwtAbstractScale

Classes

class  PrivateData
 

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.
 
virtual ~QwtKnob ()
 Destructor.
 
void setAlignment (Qt::Alignment)
 Set the alignment of the knob.
 
Qt::Alignment alignment () const
 
void setKnobWidth (int)
 Change the knob's width.
 
int knobWidth () const
 Return the width of the knob.
 
void setNumTurns (int)
 Set the number of turns.
 
int numTurns () const
 
void setTotalAngle (double angle)
 Set the total angle by which the knob can be turned.
 
double totalAngle () const
 
void setKnobStyle (KnobStyle)
 Set the knob type.
 
KnobStyle knobStyle () const
 
void setBorderWidth (int)
 Set the knob's border width.
 
int borderWidth () const
 Return the border width.
 
void setMarkerStyle (MarkerStyle)
 Set the marker type of the knob.
 
MarkerStyle markerStyle () const
 
void setMarkerSize (int)
 Set the size of the marker.
 
int markerSize () const
 
virtual QSize sizeHint () const QWT_OVERRIDE
 
virtual QSize minimumSizeHint () const QWT_OVERRIDE
 
void setScaleDraw (QwtRoundScaleDraw *)
 Change the scale draw of the knob.
 
const QwtRoundScaleDrawscaleDraw () const
 
QwtRoundScaleDrawscaleDraw ()
 
QRect knobRect () const
 Calculate the bounding rectangle of the knob without the scale.
 
- Public Member Functions inherited from QwtAbstractSlider
 QwtAbstractSlider (QWidget *parent=NULL)
 Constructor.
 
virtual ~QwtAbstractSlider ()
 Destructor.
 
void setValid (bool)
 Set the value to be valid/invalid.
 
bool isValid () const
 
double value () const
 Returns the current value.
 
void setWrapping (bool)
 If wrapping is true stepping up from upperBound() value will take you to the minimum() value and vice versa.
 
bool wrapping () const
 
void setTotalSteps (uint)
 Set the number of steps.
 
uint totalSteps () const
 
void setSingleSteps (uint)
 Set the number of steps for a single increment.
 
uint singleSteps () const
 
void setPageSteps (uint)
 Set the number of steps for a page increment.
 
uint pageSteps () const
 
void setStepAlignment (bool)
 Enable step alignment.
 
bool stepAlignment () const
 
void setTracking (bool)
 Enables or disables tracking.
 
bool isTracking () const
 
void setReadOnly (bool)
 En/Disable read only mode.
 
bool isReadOnly () const
 In read only mode the slider can't be controlled by mouse or keyboard.
 
void setInvertedControls (bool)
 Invert wheel and key events.
 
bool invertedControls () const
 
- Public Member Functions inherited from QwtAbstractScale
 QwtAbstractScale (QWidget *parent=NULL)
 Constructor.
 
virtual ~QwtAbstractScale ()
 Destructor.
 
void setScale (double lowerBound, double upperBound)
 Specify a scale.
 
void setScale (const QwtInterval &)
 Specify a scale.
 
void setScale (const QwtScaleDiv &)
 Specify a scale.
 
const QwtScaleDivscaleDiv () const
 
void setLowerBound (double value)
 Set the lower bound of the scale.
 
double lowerBound () const
 
void setUpperBound (double value)
 Set the upper bound of the scale.
 
double upperBound () const
 
void setScaleStepSize (double stepSize)
 Set the step size used for calculating a scale division.
 
double scaleStepSize () const
 
void setScaleMaxMajor (int ticks)
 Set the maximum number of major tick intervals.
 
int scaleMaxMinor () const
 
void setScaleMaxMinor (int ticks)
 Set the maximum number of minor tick intervals.
 
int scaleMaxMajor () const
 
void setScaleEngine (QwtScaleEngine *)
 Set a scale engine.
 
const QwtScaleEnginescaleEngine () const
 
QwtScaleEnginescaleEngine ()
 
int transform (double) const
 Translate a scale value into a widget coordinate.
 
double invTransform (int) const
 Translate a widget coordinate into a scale value.
 
bool isInverted () const
 
double minimum () const
 
double maximum () const
 
const QwtScaleMapscaleMap () const
 

Protected Member Functions

virtual void paintEvent (QPaintEvent *) QWT_OVERRIDE
 Repaint the knob.
 
virtual void changeEvent (QEvent *) QWT_OVERRIDE
 Handle QEvent::StyleChange and QEvent::FontChange;.
 
virtual void drawKnob (QPainter *, const QRectF &) const
 Draw the knob.
 
virtual void drawFocusIndicator (QPainter *) const
 Draw the focus indicator.
 
virtual void drawMarker (QPainter *, const QRectF &, double angle) const
 Draw the marker at the knob's front.
 
virtual double scrolledTo (const QPoint &) const QWT_OVERRIDE
 Determine the value for a new position of the mouse.
 
virtual bool isScrollPosition (const QPoint &) const QWT_OVERRIDE
 Determine what to do when the user presses a mouse button.
 
- Protected Member Functions inherited from QwtAbstractSlider
virtual void mousePressEvent (QMouseEvent *) QWT_OVERRIDE
 Mouse press event handler.
 
virtual void mouseReleaseEvent (QMouseEvent *) QWT_OVERRIDE
 Mouse Release Event handler.
 
virtual void mouseMoveEvent (QMouseEvent *) QWT_OVERRIDE
 Mouse Move Event handler.
 
virtual void keyPressEvent (QKeyEvent *) QWT_OVERRIDE
 Handles key events.
 
virtual void wheelEvent (QWheelEvent *) QWT_OVERRIDE
 Wheel Event handler.
 
void incrementValue (int stepCount)
 Increment the slider.
 
virtual void scaleChange () QWT_OVERRIDE
 Update the slider according to modifications of the scale.
 
virtual void sliderChange ()
 Calling update()
 
double incrementedValue (double value, int stepCount) const
 Increment a value.
 
- Protected Member Functions inherited from QwtAbstractScale
void rescale (double lowerBound, double upperBound, double stepSize)
 Recalculate the scale division and update the scale.
 
void setAbstractScaleDraw (QwtAbstractScaleDraw *)
 Set a scale draw.
 
const QwtAbstractScaleDrawabstractScaleDraw () const
 
QwtAbstractScaleDrawabstractScaleDraw ()
 
void updateScaleDraw ()
 Recalculate ticks and scale boundaries.
 

Properties

KnobStyle knobStyle
 
int knobWidth
 
Qt::Alignment alignment
 
double totalAngle
 
int numTurns
 
MarkerStyle markerStyle
 
int markerSize
 
int borderWidth
 
- Properties inherited from QwtAbstractSlider
double value
 
uint totalSteps
 
uint singleSteps
 
uint pageSteps
 
bool stepAlignment
 
bool readOnly
 
bool tracking
 
bool wrapping
 
bool invertedControls
 
- Properties inherited from QwtAbstractScale
double lowerBound
 
double upperBound
 
int scaleMaxMajor
 
int scaleMaxMinor
 
double scaleStepSize
 

Additional Inherited Members

- Public Slots inherited from QwtAbstractSlider
void setValue (double value)
 Set the slider to the specified value.
 
- Signals inherited from QwtAbstractSlider
void valueChanged (double value)
 Notify a change of value.
 
void sliderPressed ()
 This signal is emitted when the user presses the movable part of the slider.
 
void sliderReleased ()
 This signal is emitted when the user releases the movable part of the slider.
 
void sliderMoved (double value)
 This signal is emitted when the user moves the slider with the mouse.
 

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

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

Member Enumeration Documentation

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

◆ 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::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
parentParent widget
See also
setTotalAngle()

Member Function Documentation

◆ alignment()

Qt::Alignment QwtKnob::alignment ( ) const
Returns
Alignment of the knob inside of contentsRect()
See also
setAlignment(), knobWidth(), knobRect()

◆ changeEvent()

void QwtKnob::changeEvent ( QEvent *  event)
protectedvirtual

Handle QEvent::StyleChange and QEvent::FontChange;.

Parameters
eventChange event

Reimplemented from QwtAbstractScale.

◆ drawFocusIndicator()

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

Draw the focus indicator.

Parameters
painterPainter

◆ drawKnob()

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

Draw the knob.

Parameters
painterpainter
knobRectBounding rectangle of the knob (without scale)

◆ drawMarker()

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

Draw the marker at the knob's front.

Parameters
painterPainter
rectBounding rectangle of the knob without scale
angleAngle of the marker in degrees ( clockwise, 0 at the 12 o'clock position )

◆ isScrollPosition()

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

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

Parameters
posMouse position
Return values
True,whenpos is inside the circle of the knob.
See also
scrolledTo()

Implements QwtAbstractSlider.

◆ knobRect()

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

◆ knobStyle()

QwtKnob::KnobStyle QwtKnob::knobStyle ( ) const
Returns
Marker type of the knob
See also
setKnobStyle(), setBorderWidth()

◆ markerSize()

int QwtKnob::markerSize ( ) const
Returns
Marker size
See also
setMarkerSize()

◆ markerStyle()

QwtKnob::MarkerStyle QwtKnob::markerStyle ( ) const
Returns
Marker type of the knob
See also
setMarkerStyle(), setMarkerSize()

◆ minimumSizeHint()

QSize QwtKnob::minimumSizeHint ( ) const
virtual
Returns
Minimum size hint
See also
sizeHint()

◆ numTurns()

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

◆ paintEvent()

void QwtKnob::paintEvent ( QPaintEvent *  event)
protectedvirtual

Repaint the knob.

Parameters
eventPaint event

◆ scaleDraw() [1/2]

QwtRoundScaleDraw * QwtKnob::scaleDraw ( )
Returns
the scale draw of the knob
See also
setScaleDraw()

◆ scaleDraw() [2/2]

const QwtRoundScaleDraw * QwtKnob::scaleDraw ( ) const
Returns
the scale draw of the knob
See also
setScaleDraw()

◆ scrolledTo()

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

Determine the value for a new position of the mouse.

Parameters
posMouse position
Returns
Value for the mouse position
See also
isScrollPosition()

Implements QwtAbstractSlider.

◆ setAlignment()

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
alignmentOr'd alignment flags
See also
alignment(), setKnobWidth(), knobRect()

◆ setBorderWidth()

void QwtKnob::setBorderWidth ( int  borderWidth)

Set the knob's border width.

Parameters
borderWidthnew border width

◆ setKnobStyle()

void QwtKnob::setKnobStyle ( KnobStyle  knobStyle)

Set the knob type.

Parameters
knobStyleKnob type
See also
knobStyle(), setBorderWidth()

◆ setKnobWidth()

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
widthNew width
See also
knobWidth(), setAlignment()
Note
Modifies the sizePolicy()

◆ setMarkerSize()

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

◆ setMarkerStyle()

void QwtKnob::setMarkerStyle ( MarkerStyle  markerStyle)

Set the marker type of the knob.

Parameters
markerStyleMarker type
See also
markerStyle(), setMarkerSize()

◆ setNumTurns()

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

◆ setScaleDraw()

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

◆ setTotalAngle()

void QwtKnob::setTotalAngle ( double  angle)

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

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

◆ sizeHint()

QSize QwtKnob::sizeHint ( ) const
virtual
Returns
sizeHint()

◆ totalAngle()

double QwtKnob::totalAngle ( ) const
Returns
the total angle
See also
setTotalAngle(), setNumTurns(), numTurns()

The documentation for this class was generated from the following files: