#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);
Definition at line 45 of file qwt_analog_clock.h.
Public Types | |
enum | Hand { SecondHand, MinuteHand, HourHand, NHands } |
Public Slots | |
void | setCurrentTime () |
void | setTime (const QTime &=QTime::currentTime()) |
Public Member Functions | |
QwtAnalogClock (QWidget *parent=NULL) | |
virtual | ~QwtAnalogClock () |
virtual void | setHand (Hand, QwtDialNeedle *) |
const QwtDialNeedle * | hand (Hand) const |
QwtDialNeedle * | hand (Hand) |
Protected Member Functions | |
virtual QwtText | scaleLabel (double) const |
virtual void | drawNeedle (QPainter *, const QPoint &, int radius, double direction, QPalette::ColorGroup) const |
virtual void | drawHand (QPainter *, Hand, const QPoint &, int radius, double direction, QPalette::ColorGroup) const |
enum QwtAnalogClock::Hand |
Hand type
Definition at line 55 of file qwt_analog_clock.h.
QwtAnalogClock::QwtAnalogClock | ( | QWidget * | parent = NULL |
) | [explicit] |
QwtAnalogClock::~QwtAnalogClock | ( | ) | [virtual] |
void QwtAnalogClock::setHand | ( | Hand | hand, | |
QwtDialNeedle * | needle | |||
) | [virtual] |
Set a clockhand
hand | Specifies the type of hand | |
needle | Hand |
Definition at line 104 of file qwt_analog_clock.cpp.
References QwtDial::needle().
const QwtDialNeedle * QwtAnalogClock::hand | ( | Hand | hd | ) | const |
hd | Specifies the type of hand |
Definition at line 131 of file qwt_analog_clock.cpp.
Referenced by drawHand().
QwtDialNeedle * QwtAnalogClock::hand | ( | Hand | hd | ) |
hd | Specifies the type of hand |
Definition at line 118 of file qwt_analog_clock.cpp.
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.
Definition at line 142 of file qwt_analog_clock.cpp.
References setTime().
void QwtAnalogClock::setTime | ( | const QTime & | time = QTime::currentTime() |
) | [slot] |
Set a time
time | Time to display |
Definition at line 151 of file qwt_analog_clock.cpp.
References QwtAbstractSlider::setValid(), and QwtAbstractSlider::setValue().
Referenced by setCurrentTime().
QwtText QwtAnalogClock::scaleLabel | ( | double | value | ) | const [protected, virtual] |
Find the scale label for a given value
value | Value |
Reimplemented from QwtDial.
Definition at line 168 of file qwt_analog_clock.cpp.
void QwtAnalogClock::drawNeedle | ( | QPainter * | painter, | |
const QPoint & | center, | |||
int | radius, | |||
double | direction, | |||
QPalette::ColorGroup | cg | |||
) | 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().
painter | Painter | |
center | Center of the clock | |
radius | Maximum length for the hands | |
direction | Dummy, not used. | |
cg | ColorGroup |
Reimplemented from QwtDial.
Definition at line 191 of file qwt_analog_clock.cpp.
References drawHand(), HourHand, QwtAbstractSlider::isValid(), MinuteHand, QwtDial::origin(), SecondHand, and QwtDoubleRange::value().
void QwtAnalogClock::drawHand | ( | QPainter * | painter, | |
Hand | hd, | |||
const QPoint & | center, | |||
int | radius, | |||
double | direction, | |||
QPalette::ColorGroup | cg | |||
) | const [protected, virtual] |
Draw a clock hand
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 |
Definition at line 220 of file qwt_analog_clock.cpp.
References QwtDialNeedle::draw(), hand(), HourHand, and QwtDial::needle().
Referenced by drawNeedle().