QwtAnalogClock - Man Page

Name

QwtAnalogClock —

An analog clock.  

Synopsis

#include <qwt_analog_clock.h>

Inherits QwtDial.

Public Types

enum Direction { Clockwise, CounterClockwise }
enum Hand { SecondHand, MinuteHand, HourHand, NHands }
enum Mode { RotateNeedle, RotateScale }
enum ScaleOptions { ScaleBackbone =  1, ScaleTicks =  2, ScaleLabel =  4 }
enum ScrollMode { ScrNone, ScrMouse, ScrTimer, ScrDirect, ScrPage }
enum Shadow { Plain =  QFrame::Plain, Raised =  QFrame::Raised, Sunken =  QFrame::Sunken }

Public Slots

virtual void fitValue (double val)
virtual void incValue (int steps)
void setCurrentTime ()
virtual void setReadOnly (bool)
void setTime (const QTime &=QTime::currentTime())
virtual void setValue (double val)

Signals

void sliderMoved (double value)
void sliderPressed ()
void sliderReleased ()
void valueChanged (double value)

Public Member Functions

QRect boundingRect () const
QRect contentsRect () const
Direction direction () const
Shadow frameShadow () const
QwtDialNeedle * hand (Hand)
const QwtDialNeedle * hand (Hand) const
bool hasVisibleBackground () const
virtual void incPages (int)
bool isReadOnly () const
bool isValid () const
int lineWidth () const
virtual double mass () const
double maxScaleArc () const
double maxValue () const
virtual QSize minimumSizeHint () const
double minScaleArc () const
double minValue () const
Mode mode () const
const QwtDialNeedle * needle () const
QwtDialNeedle * needle ()
Qt::Orientation orientation () const
double origin () const
int pageSize () const
bool periodic () const
QwtAnalogClock (QWidget *parent=NULL)
virtual QRect scaleContentsRect () const
QwtDialScaleDraw * scaleDraw ()
const QwtDialScaleDraw * scaleDraw () const
void setDirection (Direction)
void setFrameShadow (Shadow)
virtual void setHand (Hand, QwtDialNeedle *)
void setLineWidth (int)
virtual void setMass (double val)
void setMode (Mode)
virtual void setOrientation (Qt::Orientation o)
virtual void setOrigin (double)
void setPeriodic (bool tf)
void setRange (double vmin, double vmax, double vstep=0.0, int pagesize=1)
virtual void setScale (int maxMajIntv, int maxMinIntv, double step=0.0)
void setScaleArc (double min, double max)
virtual void setScaleDraw (QwtDialScaleDraw *)
void setScaleOptions (int)
void setScaleTicks (int minLen, int medLen, int majLen, int penWidth=1)
void setStep (double)
void setTracking (bool enable)
void setUpdateTime (int t)
void setValid (bool valid)
virtual void setWrapping (bool)
void showBackground (bool)
virtual QSize sizeHint () const
double step () const
void stopMoving ()
double value () const
bool wrapping () const
virtual ~QwtAnalogClock ()

Protected Member Functions

virtual void drawContents (QPainter *) const
virtual void drawFocusIndicator (QPainter *) const
virtual void drawFrame (QPainter *p)
virtual void drawHand (QPainter *, Hand, const QPoint &, int radius, double direction, QPalette::ColorGroup) const
virtual void drawNeedle (QPainter *, const QPoint &, int radius, double direction, QPalette::ColorGroup) const
virtual void drawScale (QPainter *, const QPoint &center, int radius, double origin, double arcMin, double arcMax) const
virtual void drawScaleContents (QPainter *painter, const QPoint &center, int radius) const
double exactPrevValue () const
double exactValue () const
virtual void getScrollMode (const QPoint &, int &scrollMode, int &direction)
virtual double getValue (const QPoint &)
virtual void keyPressEvent (QKeyEvent *)
virtual void mouseMoveEvent (QMouseEvent *e)
double mouseOffset () const
virtual void mousePressEvent (QMouseEvent *e)
virtual void mouseReleaseEvent (QMouseEvent *e)
virtual void paintEvent (QPaintEvent *)
double prevValue () const
virtual void rangeChange ()
virtual void resizeEvent (QResizeEvent *)
virtual QwtText scaleLabel (double) const
int scrollMode () const
void setMouseOffset (double)
virtual void setPosition (const QPoint &)
virtual void stepChange ()
virtual void timerEvent (QTimerEvent *e)
virtual void updateMask ()
void updateScale ()
virtual void valueChange ()
virtual void wheelEvent (QWheelEvent *e)

Detailed Description

An analog clock.

Example

#include <qwt_analog_clock.h>

  QwtAnalogClock *clock = new QwtAnalogClock(...);
  clock->scaleDraw()->setPenWidth(3);
  clock->setLineWidth(6);
  clock->setFrameShadow(QwtDial::Sunken);
  clock->setTime();

  // update the clock every second
  QTimer *timer = new QTimer(clock);
  timer->connect(timer, SIGNAL(timeout()), clock, SLOT(setCurrentTime()));
  timer->start(1000);

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

Note:

The examples/dials example shows how to use QwtAnalogClock.

Member Enumeration Documentation

enum QwtDial::Direction [inherited] Direction of the dial

enum QwtAnalogClock::Hand Hand type

See also:

setHand(), hand()

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

enum QwtDial::ScaleOptions [inherited]

see QwtDial::setScaleOptions

enum QwtAbstractSlider::ScrollMode [inherited] Scroll mode

See also:

getScrollMode()

enum QwtDial::Shadow [inherited]

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.

Constructor & Destructor Documentation

QwtAnalogClock::QwtAnalogClock (QWidget *parent = NULL) [explicit] Constructor

Parameters:

parent Parent widget

QwtAnalogClock::~QwtAnalogClock () [virtual]

Destructor.

Member Function Documentation

QRect QwtDial::boundingRect () const [inherited] Returns

bounding rect of the dial including the frame

See also:

setLineWidth(), scaleContentsRect(), contentsRect()

QRect QwtDial::contentsRect () const [inherited] Returns

bounding rect of the circle inside the frame

See also:

setLineWidth(), scaleContentsRect(), boundingRect()

QwtDial::Direction QwtDial::direction () const [inherited] 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, inherited]

Draw the contents inside the frame. QColorGroup::Background is the background color outside of the frame. QColorGroup::Base is the background color inside the frame. QColorGroup::Foreground is the background color inside the scale.

Parameters:

painter Painter

See also:

boundingRect(), contentsRect(), scaleContentsRect(), QWidget::setPalette()

void QwtDial::drawFocusIndicator (QPainter *painter) const [protected, virtual, inherited] Draw a dotted round circle, if !isReadOnly()

Parameters:

painter Painter

void QwtDial::drawFrame (QPainter *painter) [protected, virtual, inherited] Draw the frame around the dial

Parameters:

painter Painter

See also:

lineWidth(), frameShadow()

void QwtAnalogClock::drawHand (QPainter *painter, Handhd, const QPoint &center, intradius, doubledirection, QPalette::ColorGroupcg) const [protected, virtual] Draw a clock hand

Parameters:

painter Painter
hd Specify the type of hand
center Center of the clock
radius Maximum length for the hands
direction Direction of the hand in degrees, counter clockwise
cg ColorGroup

void QwtAnalogClock::drawNeedle (QPainter *painter, const QPoint &center, intradius, doubledirection, QPalette::ColorGroupcg) const [protected, virtual]

Draw the needle. A clock has no single needle but three hands instead. drawNeedle translates value() into directions for the hands and calls drawHand().

Parameters:

painter Painter
center Center of the clock
radius Maximum length for the hands
direction Dummy, not used.
cg ColorGroup

See also:

drawHand()

Reimplemented from QwtDial.

void QwtDial::drawScale (QPainter *painter, const QPoint &center, intradius, doubleorigin, doubleminArc, doublemaxArc) const [protected, virtual, inherited] Draw the scale

Parameters:

painter Painter
center Center of the dial
radius Radius of the scale
origin Origin of the scale
minArc Minimum of the arc
maxArc Minimum of the arc

See also:

QwtAbstractScaleDraw::setAngleRange()

void QwtDial::drawScaleContents (QPainter *painter, const QPoint &center, intradius) const [protected, virtual, inherited] Draw the contents inside the scale

Paints nothing.

Parameters:

painter Painter
center Center of the contents circle
radius Radius of the contents circle

Reimplemented in QwtCompass.

double QwtDoubleRange::exactPrevValue () const [protected, inherited]

Returns the exact previous value.

double QwtDoubleRange::exactValue () const [protected, inherited]

Returns the exact value. The exact value is the value which QwtDoubleRange::value would return if the value were not adjusted to the step raster. It differs from the current value only if QwtDoubleRange::fitValue or QwtDoubleRange::incValue have been used before. This function is intended for internal use in derived classes.

void QwtAbstractSlider::fitValue (doublevalue) [virtual, slot, inherited]

Set the slider's value to the nearest integer multiple of the step size. Parameters:

value Value

See also:

setValue(), incValue()

Reimplemented from QwtDoubleRange.

QwtDial::Shadow QwtDial::frameShadow () const [inherited] Returns

Frame shadow /sa setFrameShadow(), lineWidth(), QFrame::frameShadow

void QwtDial::getScrollMode (const QPoint &pos, int &scrollMode, int &direction) [protected, virtual, inherited] See QwtAbstractSlider::getScrollMode()

Parameters:

pos point where the mouse was pressed

Return values:

scrollMode The scrolling mode
direction direction: 1, 0, or -1.

See also:

QwtAbstractSlider::getScrollMode()

Implements QwtAbstractSlider.

double QwtDial::getValue (const QPoint &pos) [protected, virtual, inherited] Find the value for a given position

Parameters:

pos Position

Returns:

Value

Implements QwtAbstractSlider.

QwtDialNeedle * QwtAnalogClock::hand (Handhd) Returns

Clock hand

Parameters:

hd Specifies the type of hand

See also:

setHand()

const QwtDialNeedle * QwtAnalogClock::hand (Handhd) const Returns

Clock hand

Parameters:

hd Specifies the type of hand

See also:

setHand()

bool QwtDial::hasVisibleBackground () const [inherited] true when the area outside of the frame is visible

See also:

showBackground(), setMask()

void QwtDoubleRange::incPages (intnPages) [virtual, inherited]

Increment the value by a specified number of pages. Parameters:

nPages Number of pages to increment. A negative number decrements the value.

Warning:

The Page size is specified in the constructor.

void QwtAbstractSlider::incValue (intsteps) [virtual, slot, inherited]

Increment the value by a specified number of steps. Parameters:

steps number of steps

See also:

setValue()

Reimplemented from QwtDoubleRange.

bool QwtAbstractSlider::isReadOnly () const [inherited] In read only mode the slider can't be controlled by mouse or keyboard.

Returns:

true if read only

See also:

setReadOnly()

bool QwtAbstractSlider::isValid () const [inline, inherited] See also

QwtDblRange::isValid()

Reimplemented from QwtDoubleRange.

void QwtDial::keyPressEvent (QKeyEvent *event) [protected, virtual, inherited] 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:

event Key event

See also:

isReadOnly()

Reimplemented from QwtAbstractSlider.

Reimplemented in QwtCompass.

int QwtDial::lineWidth () const [inherited] Returns

Line width of the frame

See also:

setLineWidth(), frameShadow(), lineWidth()

double QwtAbstractSlider::mass () const [virtual, inherited] Returns

mass

See also:

setMass()

Reimplemented in QwtWheel.

double QwtDial::maxScaleArc () const [inherited] Returns

Upper limit of the scale arc

double QwtDoubleRange::maxValue () const [inherited]

Returns the value of the second border of the range. maxValue returns the value which has been specified as the second parameter in QwtDoubleRange::setRange.

See also:

setRange()

QSize QwtDial::minimumSizeHint () const [virtual, inherited]

Return a minimum size hint. Warning:

The return value of QwtDial::minimumSizeHint() depends on the font and the scale.

double QwtDial::minScaleArc () const [inherited] Returns

Lower limit of the scale arc

double QwtDoubleRange::minValue () const [inherited]

Returns the value at the first border of the range. minValue returns the value which has been specified as the first parameter in setRange().

See also:

setRange()

QwtDial::Mode QwtDial::mode () const [inherited] 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()

void QwtAbstractSlider::mouseMoveEvent (QMouseEvent *e) [protected, virtual, inherited] Mouse Move Event handler

Parameters:

e Mouse event

void QwtAbstractSlider::mousePressEvent (QMouseEvent *e) [protected, virtual, inherited] Mouse press event handler

Parameters:

e Mouse event

void QwtAbstractSlider::mouseReleaseEvent (QMouseEvent *e) [protected, virtual, inherited] Mouse Release Event handler

Parameters:

e Mouse event

const QwtDialNeedle * QwtDial::needle () const [inherited] Returns

needle

See also:

setNeedle()

QwtDialNeedle * QwtDial::needle () [inherited] Returns

needle

See also:

setNeedle()

Qt::Orientation QwtAbstractSlider::orientation () const [inherited] Returns

Orientation

See also:

setOrientation()

double QwtDial::origin () const [inherited] The origin is the angle where scale and needle is relative to.

Returns:

Origin of the dial

See also:

setOrigin()

int QwtDoubleRange::pageSize () const [inherited]

Returns the page size in steps.

void QwtDial::paintEvent (QPaintEvent *e) [protected, virtual, inherited] Paint the dial

Parameters:

e Paint event

bool QwtDoubleRange::periodic () const [inherited]

Returns true if the range is periodic. See also:

setPeriodic()

double QwtDoubleRange::prevValue () const [protected, inherited]

Returns the previous value.

void QwtDial::rangeChange () [protected, virtual, inherited]

QwtDoubleRange update hook.

Reimplemented from QwtDoubleRange.

void QwtDial::resizeEvent (QResizeEvent *e) [protected, virtual, inherited] Resize the dial widget

Parameters:

e Resize event

QRect QwtDial::scaleContentsRect () const [virtual, inherited] Returns

rect inside the scale

See also:

setLineWidth(), boundingRect(), contentsRect()

QwtDialScaleDraw * QwtDial::scaleDraw () [inherited]

Return the scale draw.

const QwtDialScaleDraw * QwtDial::scaleDraw () const [inherited]

Return the scale draw.

QwtText QwtAnalogClock::scaleLabel (doublevalue) const [protected, virtual] Find the scale label for a given value

Parameters:

value Value

Returns:

Label

Reimplemented from QwtDial.

void QwtAnalogClock::setCurrentTime () [slot]

Set the current time. This is the same as QwtAnalogClock::setTime(), but Qt < 3.0 can't handle default parameters for slots.

void QwtDial::setDirection (Directiondirection) [inherited] Set the direction of the dial (clockwise/counterclockwise)

Direction direction

See also:

direction()

void QwtDial::setFrameShadow (Shadowshadow) [inherited] Sets the frame shadow value from the frame style.

Parameters:

shadow Frame shadow

See also:

setLineWidth(), QFrame::setFrameShadow()

void QwtAnalogClock::setHand (Handhand, QwtDialNeedle *needle) [virtual] Set a clockhand

Parameters:

hand Specifies the type of hand
needle Hand

See also:

hand()

void QwtDial::setLineWidth (intlineWidth) [inherited] Sets the line width

Parameters:

lineWidth Line width

See also:

setFrameShadow()

void QwtAbstractSlider::setMass (doubleval) [virtual, inherited]

Set the slider's mass for flywheel effect. If the slider's mass is greater then 0, it will continue to move after the mouse button has been released. Its speed decreases with time at a rate depending on the slider's mass. A large mass means that it will continue to move for a long time.

Derived widgets may overload this function to make it public.

Parameters:

val New mass in kg

See also:

mass()

Reimplemented in QwtWheel.

void QwtDial::setMode (Modemode) [inherited]

Change the mode of the meter. Parameters:

mode New 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 QwtAbstractSlider::setOrientation (Qt::Orientationo) [virtual, inherited]

Set the orientation. Parameters:

o Orientation. Allowed values are Qt::Horizontal and Qt::Vertical.

Reimplemented in QwtSlider, and QwtWheel.

void QwtDial::setOrigin (doubleorigin) [virtual, inherited]

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

Parameters:

origin New origin

See also:

origin()

void QwtDoubleRange::setPeriodic (booltf) [inherited]

Make the range periodic. When the range is periodic, the value will be set to a point inside the interval such that

point = value + n * width .fi


if the user tries to set a new value which is outside the range. If the range is nonperiodic (the default), values outside the range will be clipped.

Parameters:
  tf true for a periodic range

void QwtAbstractSlider::setPosition (const QPoint &p) [protected, virtual, inherited] Move the slider to a specified point, adjust the value and emit signals if necessary.

void QwtDoubleRange::setRange (doublevmin, doublevmax, doublevstep = 0.0, intpageSize = 1) [inherited]

Specify range and step size. Parameters:

vmin lower boundary of the interval
vmax higher boundary of the interval
vstep step width
pageSize page size in steps

Warning:
  • A change of the range changes the value if it lies outside the new range. The current value will *not* be adjusted to the new step raster.
  • vmax < vmin is allowed.
  • If the step size is left out or set to zero, it will be set to 1/100 of the interval length.
  • If the step size has an absurd value, it will be corrected to a better one.

void QwtAbstractSlider::setReadOnly (boolreadOnly) [virtual, slot, inherited] En/Disable read only mode

In read only mode the slider can't be controlled by mouse or keyboard.

Parameters:

readOnly Enables in case of true

See also:

isReadOnly()

void QwtDial::setScale (intmaxMajIntv, intmaxMinIntv, doublestep = 0.0) [virtual, inherited] Change the intervals of the scale

See also:

QwtAbstractScaleDraw::setScale()

void QwtDial::setScaleArc (doubleminArc, doublemaxArc) [inherited] Change the arc of the scale

Parameters:

minArc Lower limit
maxArc Upper limit

void QwtDial::setScaleDraw (QwtDialScaleDraw *scaleDraw) [virtual, inherited] Set an individual scale draw

Parameters:

scaleDraw Scale draw

Warning:

The previous scale draw is deleted

void QwtDial::setScaleOptions (intoptions) [inherited] A wrapper method for accessing the scale draw.

  • options == 0
    No visible scale: setScaleDraw(NULL)
  • options & ScaleBackbone
    En/disable the backbone of the scale.
  • options & ScaleTicks
    En/disable the ticks of the scale.
  • options & ScaleLabel
    En/disable scale labels

See also:

QwtAbstractScaleDraw::enableComponent()

void QwtDial::setScaleTicks (intminLen, intmedLen, intmajLen, intpenWidth = 1) [inherited] Assign length and width of the ticks

Parameters:

minLen Length of the minor ticks
medLen Length of the medium ticks
majLen Length of the major ticks
penWidth Width of the pen for all ticks

See also:

QwtAbstractScaleDraw::setTickLength(), QwtDialScaleDraw::setPenWidth()

void QwtDoubleRange::setStep (doublevstep) [inherited]

Change the step raster. Parameters:

vstep new step width

Warning:

The value will not be adjusted to the new step raster.

Reimplemented in QwtCounter.

void QwtAnalogClock::setTime (const QTime &time = QTime::currentTime()) [slot] Set a time

Parameters:

time Time to display

void QwtAbstractSlider::setTracking (boolenable) [inherited]

Enables or disables tracking. If tracking is enabled, the slider emits a valueChanged() signal whenever its value changes (the default behaviour). If tracking is disabled, the value changed() signal will only be emitted if:

  • the user releases the mouse button and the value has changed or
  • at the end of automatic scrolling.

Tracking is enabled by default.

Parameters:

enable true (enable) or false (disable) tracking.

void QwtAbstractSlider::setUpdateTime (intt) [inherited]

Specify the update interval for automatic scrolling. Parameters:

t update interval in milliseconds

See also:

getScrollMode()

void QwtAbstractSlider::setValid (boolvalid) [inline, inherited] Parameters

valid true/false

See also:

QwtDblRange::isValid()

Reimplemented from QwtDoubleRange.

void QwtAbstractSlider::setValue (doubleval) [virtual, slot, inherited]

Move the slider to a specified value. This function can be used to move the slider to a value which is not an integer multiple of the step size.

Parameters:

val new value

See also:

fitValue()

Reimplemented from QwtDoubleRange.

void QwtDial::setWrapping (boolwrapping) [virtual, inherited] Sets whether it is possible to step the value from the highest value to the lowest value and vice versa to on.

Parameters:

wrapping en/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.

void QwtDial::showBackground (boolshow) [inherited] Show/Hide the area outside of the frame

Parameters:

show Show if true, hide if false

See also:

hasVisibleBackground(), setMask()

Warning:

When QwtDial is a toplevel widget the window border might disappear too.

QSize QwtDial::sizeHint () const [virtual, inherited] Returns

Size hint

void QwtAbstractSlider::sliderMoved (doublevalue) [signal, inherited] This signal is emitted when the user moves the slider with the mouse.

Parameters:

value new value

void QwtAbstractSlider::sliderPressed () [signal, inherited] This signal is emitted when the user presses the movable part of the slider (start ScrMouse Mode).

void QwtAbstractSlider::sliderReleased () [signal, inherited] This signal is emitted when the user releases the movable part of the slider.

double QwtDoubleRange::step () const [inherited] Returns

the step size

See also:

setStep(), setRange()

Reimplemented in QwtCounter.

void QwtDoubleRange::stepChange () [protected, virtual, inherited]

Notify a change of the step size. This virtual function is called whenever the step size changes. The default implementation does nothing.

void QwtAbstractSlider::stopMoving () [inherited]

Stop updating if automatic scrolling is active.

void QwtAbstractSlider::timerEvent (QTimerEvent *e) [protected, virtual, inherited] Qt timer event

Parameters:

e Timer event

void QwtDial::updateMask () [protected, virtual, inherited]

Update the mask of the dial. In case of 'hasVisibleBackground() == false', the backgound is transparent by a mask.

See also:

showBackground(), hasVisibleBackground()

void QwtDial::updateScale () [protected, inherited] Update the scale with the current attributes

See also:

setScale()

double QwtDoubleRange::value () const [inherited]

Returns the current value.

Reimplemented in QwtCounter.

void QwtDial::valueChange () [protected, virtual, inherited]

QwtDoubleRange update hook.

Reimplemented from QwtAbstractSlider.

void QwtAbstractSlider::valueChanged (doublevalue) [signal, inherited]

Notify a change of value. In the default setting (tracking enabled), this signal will be emitted every time the value changes ( see setTracking() ).

Parameters:

value new value

void QwtAbstractSlider::wheelEvent (QWheelEvent *e) [protected, virtual, inherited] Wheel Event handler

Parameters:

e Whell event

bool QwtDial::wrapping () const [inherited] 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.

Author

Generated automatically by Doxygen for Qwt User's Guide from the source code.

Info

Mon Aug 1 2011 Version 5.2.2 Qwt User's Guide