Qwt User's Guide 6.0.0
Public Types | Public Member Functions | Protected Member Functions | Friends

QwtDial Class Reference

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

#include <qwt_dial.h>

Inheritance diagram for QwtDial:
Inheritance graph
[legend]

List of all members.

Public Types

enum  Shadow {
  Plain = QFrame::Plain,
  Raised = QFrame::Raised,
  Sunken = QFrame::Sunken
}
enum  Mode {
  RotateNeedle,
  RotateScale
}
enum  Direction {
  Clockwise,
  CounterClockwise
}

Public Member Functions

 QwtDial (QWidget *parent=NULL)
virtual ~QwtDial ()
void setFrameShadow (Shadow)
Shadow frameShadow () const
void setLineWidth (int)
int lineWidth () const
void setMode (Mode)
Mode mode () const
virtual void setWrapping (bool)
bool wrapping () const
virtual void setScale (int maxMajIntv, int maxMinIntv, double step=0.0)
void setScaleArc (double min, double max)
void setScaleComponents (QwtAbstractScaleDraw::ScaleComponents)
void setScaleTicks (int minLen, int medLen, int majLen, int penWidth=1)
double minScaleArc () const
double maxScaleArc () const
virtual void setOrigin (double)
double origin () const
void setDirection (Direction)
Direction direction () const
virtual void setNeedle (QwtDialNeedle *)
const QwtDialNeedleneedle () const
QwtDialNeedleneedle ()
QRectF boundingRect () const
QRectF innerRect () const
virtual QRectF scaleInnerRect () const
virtual QSize sizeHint () const
virtual QSize minimumSizeHint () const
virtual void setScaleDraw (QwtDialScaleDraw *)
QwtDialScaleDrawscaleDraw ()
const QwtDialScaleDrawscaleDraw () const

Protected Member Functions

virtual void paintEvent (QPaintEvent *)
virtual void keyPressEvent (QKeyEvent *)
virtual void drawFrame (QPainter *p)
virtual void drawContents (QPainter *) const
virtual void drawFocusIndicator (QPainter *) const
virtual void drawScale (QPainter *, const QPointF &center, double radius, double origin, double arcMin, double arcMax) 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 QwtText scaleLabel (double) const
void updateScale ()
virtual void rangeChange ()
virtual void valueChange ()
virtual double getValue (const QPoint &)
virtual void getScrollMode (const QPoint &, QwtAbstractSlider::ScrollMode &, int &direction) const

Friends

class QwtDialScaleDraw

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

Qwt is missing a set of good looking needles (QwtDialNeedle). Contributions are very welcome.

See also:
QwtCompass, QwtAnalogClock, QwtDialNeedle
Note:
The examples/dials example shows different types of dials.

Member Enumeration Documentation

Direction of the dial.

Enumerator:
Clockwise 

Clockwise.

CounterClockwise 

Counter clockwise.

Mode controlling wether 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 scale and no needle. The default origin is 90.0 with no valid value. It accepts mouse and keyboard inputs and has no step size. The default mode is QwtDial::RotateNeedle.

QwtDial::~QwtDial ( ) [virtual]

Destructor.


Member Function Documentation

QRectF QwtDial::boundingRect ( ) const
Returns:
bounding rect of the dial including the frame
See also:
setLineWidth(), scaleInnerRect(), innerRect()
QwtDial::Direction QwtDial::direction ( ) const
Returns:
Direction of the dial

The default direction of a dial is QwtDial::Clockwise

See also:
setDirection()
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 a dotted round circle, if !isReadOnly()

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  cg 
) const [protected, virtual]

Draw the needle

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

Reimplemented in QwtAnalogClock.

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

Draw the scale

Parameters:
painterPainter
centerCenter of the dial
radiusRadius of the scale
originOrigin of the scale
minArcMinimum of the arc
maxArcMinimum of the arc
See also:
QwtRoundScaleDraw::setAngleRange()
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.

QwtDial::Shadow QwtDial::frameShadow ( ) const
Returns:
Frame shadow /sa setFrameShadow(), lineWidth(), QFrame::frameShadow
void QwtDial::getScrollMode ( const QPoint &  pos,
QwtAbstractSlider::ScrollMode scrollMode,
int &  direction 
) const [protected, virtual]

See QwtAbstractSlider::getScrollMode()

Parameters:
pospoint where the mouse was pressed
Return values:
scrollModeThe scrolling mode
directiondirection: 1, 0, or -1.
See also:
QwtAbstractSlider::getScrollMode()

Implements QwtAbstractSlider.

double QwtDial::getValue ( const QPoint &  pos) [protected, virtual]

Find the value for a given position

Parameters:
posPosition
Returns:
Value

Implements QwtAbstractSlider.

QRectF QwtDial::innerRect ( ) const
Returns:
bounding rect of the circle inside the frame
See also:
setLineWidth(), scaleInnerRect(), boundingRect()
void QwtDial::keyPressEvent ( QKeyEvent *  event) [protected, virtual]

Handles key events

  • Key_Down, KeyLeft
    Decrement by 1
  • Key_Prior
    Decrement by pageSize()
  • Key_Home
    Set the value to minValue()
  • Key_Up, KeyRight
    Increment by 1
  • Key_Next
    Increment by pageSize()
  • Key_End
    Set the value to maxValue()
Parameters:
eventKey event
See also:
isReadOnly()

Reimplemented from QwtAbstractSlider.

Reimplemented in QwtCompass.

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
QSize QwtDial::minimumSizeHint ( ) const [virtual]

Return a minimum size hint.

Warning:
The return value of QwtDial::minimumSizeHint() depends on the font and the scale.
double QwtDial::minScaleArc ( ) const
Returns:
Lower limit of the scale arc
QwtDial::Mode QwtDial::mode ( ) const
Returns:
mode of the dial.

The value of the dial is indicated by the difference between the origin and the direction of the needle. In case of QwtDial::RotateNeedle the scale arc is fixed to the origin() and 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:
setMode(), origin(), setScaleArc(), value()
QwtDialNeedle * QwtDial::needle ( )
Returns:
needle
See also:
setNeedle()
const QwtDialNeedle * QwtDial::needle ( ) const
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::rangeChange ( ) [protected, virtual]

QwtDoubleRange update hook.

Reimplemented from QwtDoubleRange.

QwtDialScaleDraw * QwtDial::scaleDraw ( )

Return the scale draw.

const QwtDialScaleDraw * QwtDial::scaleDraw ( ) const

Return the scale draw.

QRectF QwtDial::scaleInnerRect ( ) const [virtual]
Returns:
rect inside the scale
See also:
setLineWidth(), boundingRect(), innerRect()
QwtText QwtDial::scaleLabel ( double  value) const [protected, virtual]

Find the label for a value

Parameters:
valueValue
Returns:
label

Reimplemented in QwtAnalogClock, and QwtCompass.

void QwtDial::setDirection ( Direction  direction)

Set the direction of the dial (clockwise/counterclockwise)

Parameters:
directionDirection
See also:
direction()
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

Parameters:
lineWidthLine width
See also:
setFrameShadow()
void QwtDial::setMode ( Mode  mode)

Change the mode of the meter.

Parameters:
modeNew mode

The value of the meter is indicated by the difference between north of the scale and the direction of the needle. In case of QwtDial::RotateNeedle north is pointing to the origin() and 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) [virtual]

Set a needle for the dial

Qwt is missing a set of good looking needles. Contributions are very welcome.

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::setScale ( int  maxMajIntv,
int  maxMinIntv,
double  step = 0.0 
) [virtual]

Change the intervals of the scale

Parameters:
maxMajIntvMaximum for the number of major steps
maxMinIntvMaximum number of minor steps
stepStep size
See also:
QwtScaleEngine::divideScale()
void QwtDial::setScaleArc ( double  minArc,
double  maxArc 
)

Change the arc of the scale

Parameters:
minArcLower limit
maxArcUpper limit
void QwtDial::setScaleComponents ( QwtAbstractScaleDraw::ScaleComponents  components)

A wrapper method for accessing the scale draw.

Parameters:
componentsScale components
See also:
QwtAbstractScaleDraw::enableComponent()
void QwtDial::setScaleDraw ( QwtDialScaleDraw scaleDraw) [virtual]

Set an individual scale draw

Parameters:
scaleDrawScale draw
Warning:
The previous scale draw is deleted
void QwtDial::setScaleTicks ( int  minLen,
int  medLen,
int  majLen,
int  penWidth = 1 
)

Assign length and width of the ticks

Parameters:
minLenLength of the minor ticks
medLenLength of the medium ticks
majLenLength of the major ticks
penWidthWidth of the pen for all ticks
See also:
QwtAbstractScaleDraw::setTickLength(), QwtDialScaleDraw::setPenWidth()
void QwtDial::setWrapping ( bool  wrapping) [virtual]

Sets whether it is possible to step the value from the highest value to the lowest value and vice versa to on.

Parameters:
wrappingen/disables wrapping
See also:
wrapping(), QwtDoubleRange::periodic()
Note:
The meaning of wrapping is like the wrapping property of QSpinBox, but not like it is used in QDial.
QSize QwtDial::sizeHint ( ) const [virtual]
Returns:
Size hint
void QwtDial::updateScale ( ) [protected]

Update the scale with the current attributes

See also:
setScale()
void QwtDial::valueChange ( ) [protected, virtual]

QwtDoubleRange update hook.

Reimplemented from QwtAbstractSlider.

bool QwtDial::wrapping ( ) const

wrapping() holds whether it is possible to step the value from the highest value to the lowest value and vice versa.

See also:
setWrapping(), QwtDoubleRange::setPeriodic()
Note:
The meaning of wrapping is like the wrapping property of QSpinBox, but not like it is used in QDial.