#include "digitalclock.h" #include #include DigitalClock::DigitalClock(QWidget *parent) : QLabel(parent) { QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), SLOT(updateView())); updateView(); timer->start(100); } void DigitalClock::updateView() { static const QString format("\ \ %1:%2
%3, %4 %5"); QDateTime dt = QDateTime::currentDateTime(); setText(format .arg(dt.time().hour(), 2, 10, QLatin1Char('0')) .arg(dt.time().minute(), 2, 10, QLatin1Char('0')) .arg(QDate::longDayName(dt.date().dayOfWeek())) .arg(QDate::longMonthName(dt.date().month())) .arg(dt.date().day())); }