|  | Home · All Classes · Main Classes · Annotated · Grouped Classes · Functions |

# digitalclock.cpp Example File
widgets/digitalclock/digitalclock.cpp

        #include <QtGui>

        #include "digitalclock.h"

        DigitalClock::DigitalClock(QWidget *parent)
            : QLCDNumber(parent)
        {
            setSegmentStyle(Filled);

            QTimer *timer = new QTimer(this);
            connect(timer, SIGNAL(timeout()), this, SLOT(showTime()));
            timer->start(1000);

            showTime();

            setWindowTitle(tr("Digital Clock"));
            resize(150, 60);
        }

        void DigitalClock::showTime()
        {
            QTime time = QTime::currentTime();
            QString text = time.toString().left(5);
            if ((time.second() % 2) == 0)
                text[2] = ' ';
            display(text);
        }