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

QwtDial class provides a rounded range control. More...

#include <qwt_dial.h>

Inheritance diagram for QwtDial:
QwtAbstractSlider QwtAbstractScale QwtAnalogClock QwtCompass

Classes

class  PrivateData
 

Public Types

enum  Shadow { Plain = QFrame::Plain , Raised = QFrame::Raised , Sunken = QFrame::Sunken }
 Frame shadow. More...
 
enum  Mode { RotateNeedle , RotateScale }
 Mode controlling whether the needle or the scale is rotating. More...
 

Public Member Functions

 QwtDial (QWidget *parent=NULL)
 Constructor.
 
virtual ~QwtDial ()
 Destructor.
 
void setFrameShadow (Shadow)
 Sets the frame shadow value from the frame style.
 
Shadow frameShadow () const
 
void setLineWidth (int)
 Sets the line width of the frame.
 
int lineWidth () const
 
void setMode (Mode)
 Change the mode of the dial.
 
Mode mode () const
 
void setScaleArc (double minArc, double maxArc)
 Change the arc of the scale.
 
void setMinScaleArc (double)
 Set the lower limit for the scale arc.
 
double minScaleArc () const
 
void setMaxScaleArc (double)
 Set the upper limit for the scale arc.
 
double maxScaleArc () const
 
virtual void setOrigin (double)
 Change the origin.
 
double origin () const
 The origin is the angle where scale and needle is relative to.
 
void setNeedle (QwtDialNeedle *)
 Set a needle for the dial.
 
const QwtDialNeedleneedle () const
 
QwtDialNeedleneedle ()
 
QRect boundingRect () const
 
QRect innerRect () const
 
virtual QRect scaleInnerRect () const
 
virtual QSize sizeHint () const QWT_OVERRIDE
 
virtual QSize minimumSizeHint () const QWT_OVERRIDE
 
void setScaleDraw (QwtRoundScaleDraw *)
 Set an individual scale draw.
 
QwtRoundScaleDrawscaleDraw ()
 
const QwtRoundScaleDrawscaleDraw () const
 
- 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 wheelEvent (QWheelEvent *) QWT_OVERRIDE
 Wheel Event handler.
 
virtual void paintEvent (QPaintEvent *) QWT_OVERRIDE
 Paint the dial.
 
virtual void changeEvent (QEvent *) QWT_OVERRIDE
 Change Event handler.
 
virtual void drawFrame (QPainter *)
 Draw the frame around the dial.
 
virtual void drawContents (QPainter *) const
 Draw the contents inside the frame.
 
virtual void drawFocusIndicator (QPainter *) const
 Draw the focus indicator.
 
void invalidateCache ()
 Invalidate the internal caches used to speed up repainting.
 
virtual void drawScale (QPainter *, const QPointF &center, double radius) const
 Draw the scale.
 
virtual void drawScaleContents (QPainter *painter, const QPointF &center, double radius) const
 Draw the contents inside the scale.
 
virtual void drawNeedle (QPainter *, const QPointF &, double radius, double direction, QPalette::ColorGroup) const
 Draw the needle.
 
virtual double scrolledTo (const QPoint &) const QWT_OVERRIDE
 Determine the value for a new position of the slider handle.
 
virtual bool isScrollPosition (const QPoint &) const QWT_OVERRIDE
 Determine what to do when the user presses a mouse button.
 
virtual void sliderChange () QWT_OVERRIDE
 Calling update()
 
virtual void scaleChange () QWT_OVERRIDE
 Invalidate the internal caches and call QwtAbstractSlider::scaleChange()
 
- 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.
 
void incrementValue (int stepCount)
 Increment the slider.
 
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

int lineWidth
 
Shadow frameShadow
 
Mode mode
 
double origin
 
double minScaleArc
 
double maxScaleArc
 
- 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

QwtDial class provides a rounded range control.

QwtDial is intended as base class for dial widgets like speedometers, compass widgets, clocks ...

A dial contains a scale and a needle indicating the current value of the dial. Depending on Mode one of them is fixed and the other is rotating. If not isReadOnly() the dial can be rotated by dragging the mouse or using keyboard inputs (see QwtAbstractSlider::keyPressEvent()). A dial might be wrapping, what means a rotation below/above one limit continues on the other limit (f.e compass). The scale might cover any arc of the dial, its values are related to the origin() of the dial.

Often dials have to be updated very often according to values from external devices. For these high refresh rates QwtDial caches as much as possible. For derived classes it might be necessary to clear these caches manually according to attribute changes using invalidateCache().

See also
QwtCompass, QwtAnalogClock, QwtDialNeedle
Note
The controls and dials examples shows different types of dials.
QDial is more similar to QwtKnob than to QwtDial

Member Enumeration Documentation

◆ Mode

Mode controlling whether the needle or the scale is rotating.

Enumerator
RotateNeedle 

The needle is rotating.

RotateScale 

The needle is fixed, the scales are rotating.

◆ Shadow

Frame shadow.

Unfortunately it is not possible to use QFrame::Shadow as a property of a widget that is not derived from QFrame. The following enum is made for the designer only. It is safe to use QFrame::Shadow instead.

Enumerator
Plain 

QFrame::Plain.

Raised 

QFrame::Raised.

Sunken 

QFrame::Sunken.

Constructor & Destructor Documentation

◆ QwtDial()

QwtDial::QwtDial ( QWidget *  parent = NULL)
explicit

Constructor.

Parameters
parentParent widget

Create a dial widget with no needle. The scale is initialized to [ 0.0, 360.0 ] and 360 steps ( QwtAbstractSlider::setTotalSteps() ). The origin of the scale is at 90°,

The value is set to 0.0.

The default mode is QwtDial::RotateNeedle.

Member Function Documentation

◆ boundingRect()

QRect QwtDial::boundingRect ( ) const
Returns
bounding rectangle of the dial including the frame
See also
setLineWidth(), scaleInnerRect(), innerRect()

◆ changeEvent()

void QwtDial::changeEvent ( QEvent *  event)
protectedvirtual

Change Event handler.

Parameters
eventChange event

Invalidates internal paint caches if necessary

Reimplemented from QwtAbstractScale.

◆ drawContents()

void QwtDial::drawContents ( QPainter *  painter) const
protectedvirtual

Draw the contents inside the frame.

QPalette::Window is the background color outside of the frame. QPalette::Base is the background color inside the frame. QPalette::WindowText is the background color inside the scale.

Parameters
painterPainter
See also
boundingRect(), innerRect(), scaleInnerRect(), QWidget::setPalette()

◆ drawFocusIndicator()

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

Draw the focus indicator.

Parameters
painterPainter

◆ drawFrame()

void QwtDial::drawFrame ( QPainter *  painter)
protectedvirtual

Draw the frame around the dial.

Parameters
painterPainter
See also
lineWidth(), frameShadow()

◆ drawNeedle()

void QwtDial::drawNeedle ( QPainter *  painter,
const QPointF &  center,
double  radius,
double  direction,
QPalette::ColorGroup  colorGroup 
) const
protectedvirtual

Draw the needle.

Parameters
painterPainter
centerCenter of the dial
radiusLength for the needle
directionDirection of the needle in degrees, counter clockwise
colorGroupColorGroup

Reimplemented in QwtAnalogClock.

◆ drawScale()

void QwtDial::drawScale ( QPainter *  painter,
const QPointF &  center,
double  radius 
) const
protectedvirtual

Draw the scale.

Parameters
painterPainter
centerCenter of the dial
radiusRadius of the scale

◆ drawScaleContents()

void QwtDial::drawScaleContents ( QPainter *  painter,
const QPointF &  center,
double  radius 
) const
protectedvirtual

Draw the contents inside the scale.

Paints nothing.

Parameters
painterPainter
centerCenter of the contents circle
radiusRadius of the contents circle

Reimplemented in QwtCompass.

◆ frameShadow()

QwtDial::Shadow QwtDial::frameShadow ( ) const
Returns
Frame shadow /sa setFrameShadow(), lineWidth(), QFrame::frameShadow()

◆ innerRect()

QRect QwtDial::innerRect ( ) const
Returns
bounding rectangle of the circle inside the frame
See also
setLineWidth(), scaleInnerRect(), boundingRect()

◆ isScrollPosition()

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

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

Parameters
posMouse position
Return values
True,whenthe inner circle contains pos
See also
scrolledTo()

Implements QwtAbstractSlider.

◆ lineWidth()

int QwtDial::lineWidth ( ) const
Returns
Line width of the frame
See also
setLineWidth(), frameShadow(), lineWidth()

◆ maxScaleArc()

double QwtDial::maxScaleArc ( ) const
Returns
Upper limit of the scale arc
See also
setScaleArc()

◆ minimumSizeHint()

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

◆ minScaleArc()

double QwtDial::minScaleArc ( ) const
Returns
Lower limit of the scale arc
See also
setScaleArc()

◆ mode()

QwtDial::Mode QwtDial::mode ( ) const
Returns
Mode of the dial.
See also
setMode(), origin(), setScaleArc(), value()

◆ needle() [1/2]

QwtDialNeedle * QwtDial::needle ( )
Returns
needle
See also
setNeedle()

◆ needle() [2/2]

const QwtDialNeedle * QwtDial::needle ( ) const
Returns
needle
See also
setNeedle()

◆ origin()

double QwtDial::origin ( ) const

The origin is the angle where scale and needle is relative to.

Returns
Origin of the dial
See also
setOrigin()

◆ paintEvent()

void QwtDial::paintEvent ( QPaintEvent *  event)
protectedvirtual

Paint the dial.

Parameters
eventPaint event

◆ scaleChange()

void QwtDial::scaleChange ( )
protectedvirtual

Invalidate the internal caches and call QwtAbstractSlider::scaleChange()

Reimplemented from QwtAbstractSlider.

◆ scaleDraw() [1/2]

QwtRoundScaleDraw * QwtDial::scaleDraw ( )
Returns
the scale draw

◆ scaleDraw() [2/2]

const QwtRoundScaleDraw * QwtDial::scaleDraw ( ) const
Returns
the scale draw

◆ scaleInnerRect()

QRect QwtDial::scaleInnerRect ( ) const
virtual
Returns
rectangle inside the scale
See also
setLineWidth(), boundingRect(), innerRect()

◆ scrolledTo()

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

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.

◆ setFrameShadow()

void QwtDial::setFrameShadow ( Shadow  shadow)

Sets the frame shadow value from the frame style.

Parameters
shadowFrame shadow
See also
setLineWidth(), QFrame::setFrameShadow()

◆ setLineWidth()

void QwtDial::setLineWidth ( int  lineWidth)

Sets the line width of the frame.

Parameters
lineWidthLine width
See also
setFrameShadow()

◆ setMaxScaleArc()

void QwtDial::setMaxScaleArc ( double  max)

Set the upper limit for the scale arc.

Parameters
maxUpper limit of the scale arc
See also
setScaleArc(), setMinScaleArc()

◆ setMinScaleArc()

void QwtDial::setMinScaleArc ( double  min)

Set the lower limit for the scale arc.

Parameters
minLower limit of the scale arc
See also
setScaleArc(), setMaxScaleArc()

◆ setMode()

void QwtDial::setMode ( Mode  mode)

Change the mode of the dial.

Parameters
modeNew mode

In case of QwtDial::RotateNeedle the needle is rotating, in case of QwtDial::RotateScale, the needle points to origin() and the scale is rotating.

The default mode is QwtDial::RotateNeedle.

See also
mode(), setValue(), setOrigin()

◆ setNeedle()

void QwtDial::setNeedle ( QwtDialNeedle needle)

Set a needle for the dial.

Parameters
needleNeedle
Warning
The needle will be deleted, when a different needle is set or in ~QwtDial()

◆ setOrigin()

void QwtDial::setOrigin ( double  origin)
virtual

Change the origin.

The origin is the angle where scale and needle is relative to.

Parameters
originNew origin
See also
origin()

◆ setScaleArc()

void QwtDial::setScaleArc ( double  minArc,
double  maxArc 
)

Change the arc of the scale.

Parameters
minArcLower limit
maxArcUpper limit
See also
minScaleArc(), maxScaleArc()

◆ setScaleDraw()

void QwtDial::setScaleDraw ( QwtRoundScaleDraw scaleDraw)

Set an individual scale draw.

The motivation for setting a scale draw is often to overload QwtRoundScaleDraw::label() to return individual tick labels.

Parameters
scaleDrawScale draw
Warning
The previous scale draw is deleted

◆ sizeHint()

QSize QwtDial::sizeHint ( ) const
virtual
Returns
Size hint
See also
minimumSizeHint()

◆ sliderChange()

void QwtDial::sliderChange ( )
protectedvirtual

Calling update()

Reimplemented from QwtAbstractSlider.

◆ wheelEvent()

void QwtDial::wheelEvent ( QWheelEvent *  event)
protectedvirtual

Wheel Event handler.

Parameters
eventWheel event

Reimplemented from QwtAbstractSlider.


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