Qwt User's Guide
QwtDial Class Reference

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

#include <qwt_dial.h>

Inheritance diagram for QwtDial:

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)
Shadow frameShadow () const
void setLineWidth (int)
int lineWidth () const
void setMode (Mode)
 Change the mode of the dial.
Mode mode () const
void setScaleArc (double min, double max)
void setMinScaleArc (double min)
double minScaleArc () const
void setMaxScaleArc (double min)
double maxScaleArc () const
virtual void setOrigin (double)
 Change the origin.
double origin () const
void setNeedle (QwtDialNeedle *)
const QwtDialNeedleneedle () const
QwtDialNeedleneedle ()
QRect boundingRect () const
QRect innerRect () const
virtual QRect scaleInnerRect () const
virtual QSize sizeHint () const
virtual QSize minimumSizeHint () const
void setScaleDraw (QwtRoundScaleDraw *)
QwtRoundScaleDrawscaleDraw ()
const QwtRoundScaleDrawscaleDraw () const

Protected Member Functions

virtual void wheelEvent (QWheelEvent *)
virtual void paintEvent (QPaintEvent *)
virtual void changeEvent (QEvent *)
virtual void drawFrame (QPainter *p)
virtual void drawContents (QPainter *) const
 Draw the contents inside the frame.
virtual void drawFocusIndicator (QPainter *) const
void invalidateCache ()
virtual void drawScale (QPainter *, const QPointF &center, double radius) const
virtual void drawScaleContents (QPainter *painter, const QPointF &center, double radius) const
virtual void drawNeedle (QPainter *, const QPointF &, double radius, double direction, QPalette::ColorGroup) const
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 sliderChange ()
 Calling update()
virtual void scaleChange ()

Detailed Description

QwtDial class provides a rounded range control.

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

dials2.png

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 controlling whether the needle or the scale is rotating.

Enumerator:
RotateNeedle 

The needle is rotating.

RotateScale 

The needle is fixed, the scales are rotating.

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

QRect QwtDial::boundingRect ( ) const
Returns:
bounding rectangle of the dial including the frame
See also:
setLineWidth(), scaleInnerRect(), innerRect()
void QwtDial::changeEvent ( QEvent *  event) [protected, virtual]

Change Event handler

Parameters:
eventChange event

Invalidates internal paint caches if necessary

void QwtDial::drawContents ( QPainter *  painter) const [protected, virtual]

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()
void QwtDial::drawFocusIndicator ( QPainter *  painter) const [protected, virtual]

Draw the focus indicator

Parameters:
painterPainter
void QwtDial::drawFrame ( QPainter *  painter) [protected, virtual]

Draw the frame around the dial

Parameters:
painterPainter
See also:
lineWidth(), frameShadow()
void QwtDial::drawNeedle ( QPainter *  painter,
const QPointF &  center,
double  radius,
double  direction,
QPalette::ColorGroup  colorGroup 
) const [protected, virtual]

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.

void QwtDial::drawScale ( QPainter *  painter,
const QPointF &  center,
double  radius 
) const [protected, virtual]

Draw the scale

Parameters:
painterPainter
centerCenter of the dial
radiusRadius of the scale
void QwtDial::drawScaleContents ( QPainter *  painter,
const QPointF &  center,
double  radius 
) const [protected, virtual]

Draw the contents inside the scale

Paints nothing.

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

Reimplemented in QwtCompass.

Returns:
Frame shadow /sa setFrameShadow(), lineWidth(), QFrame::frameShadow()
QRect QwtDial::innerRect ( ) const
Returns:
bounding rectangle of the circle inside the frame
See also:
setLineWidth(), scaleInnerRect(), boundingRect()
void QwtDial::invalidateCache ( ) [protected]

Invalidate the internal caches used to speed up repainting

bool QwtDial::isScrollPosition ( const QPoint &  pos) const [protected, virtual]

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.

int QwtDial::lineWidth ( ) const
Returns:
Line width of the frame
See also:
setLineWidth(), frameShadow(), lineWidth()
double QwtDial::maxScaleArc ( ) const
Returns:
Upper limit of the scale arc
See also:
setScaleArc()
QSize QwtDial::minimumSizeHint ( ) const [virtual]
Returns:
Minimum size hint
See also:
sizeHint()
double QwtDial::minScaleArc ( ) const
Returns:
Lower limit of the scale arc
See also:
setScaleArc()
Returns:
Mode of the dial.
See also:
setMode(), origin(), setScaleArc(), value()
const QwtDialNeedle * QwtDial::needle ( ) const
Returns:
needle
See also:
setNeedle()
Returns:
needle
See also:
setNeedle()
double QwtDial::origin ( ) const

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

Returns:
Origin of the dial
See also:
setOrigin()
void QwtDial::paintEvent ( QPaintEvent *  event) [protected, virtual]

Paint the dial

Parameters:
eventPaint event
void QwtDial::scaleChange ( ) [protected, virtual]

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

Reimplemented from QwtAbstractSlider.

Returns:
the scale draw
Returns:
the scale draw
QRect QwtDial::scaleInnerRect ( ) const [virtual]
Returns:
rectangle inside the scale
See also:
setLineWidth(), boundingRect(), innerRect()
double QwtDial::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 QwtDial::setFrameShadow ( Shadow  shadow)

Sets the frame shadow value from the frame style.

Parameters:
shadowFrame shadow
See also:
setLineWidth(), QFrame::setFrameShadow()
void QwtDial::setLineWidth ( int  lineWidth)

Sets the line width of the frame

Parameters:
lineWidthLine width
See also:
setFrameShadow()
void QwtDial::setMaxScaleArc ( double  max)

Set the upper limit for the scale arc

Parameters:
maxUpper limit of the scale arc
See also:
setScaleArc(), 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()
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()
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()
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()
void QwtDial::setScaleArc ( double  minArc,
double  maxArc 
)

Change the arc of the scale

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

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
QSize QwtDial::sizeHint ( ) const [virtual]
Returns:
Size hint
See also:
minimumSizeHint()
void QwtDial::wheelEvent ( QWheelEvent *  event) [protected, virtual]

Wheel Event handler

Parameters:
eventWheel event

Reimplemented from QwtAbstractSlider.

List of all members.

 All Classes Functions Variables Typedefs Enumerations Enumerator