-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmclock.cpp
More file actions
28 lines (24 loc) · 764 Bytes
/
smclock.cpp
File metadata and controls
28 lines (24 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "smclock.h"
#include <QDateTime>
#include <QPainter>
SMClock::SMClock(QWidget *parent) : QWidget(parent),
_layout(this)
{
_dateLabel.setText("filler");
_dateLabel.setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
_timeLabel.setText("filler");
_timeLabel.setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
_layout.addWidget(&_dateLabel);
_layout.addWidget(&_timeLabel);
}
void SMClock::setColor(const QColor & c)
{
_dateLabel.setColor(c);
_timeLabel.setColor(c);
}
void SMClock::update()
{
QDateTime currentDateTime = QDateTime::currentDateTime();
_dateLabel.setTextAndScale(currentDateTime.date().toString("ddd dd MMM yyyy"));
_timeLabel.setTextAndScale(currentDateTime.time().toString("HH:mm:ss"));
}