Qt 5.10 Book Examples
chapter37
Clock
Clock.h
Go to the documentation of this file.
1
// ======================================================================
2
// Clock.h
3
// ======================================================================
4
// This file is a part of the book
5
// "Qt 5.10 Professional programming with C++"
6
// http://qt-book.com
7
// ======================================================================
8
// Copyright (c) 2017 by Max Schlee
9
// ======================================================================
10
11
#pragma once
12
13
#include <QtWidgets>
14
15
// ======================================================================
16
class
Clock
:
public
QLabel {
17
Q_OBJECT
18
19
public
:
20
Clock
(QWidget* pwgt = 0) : QLabel(pwgt)
21
{
22
QTimer* ptimer =
new
QTimer(
this
);
23
connect(ptimer, SIGNAL(timeout()), SLOT(
slotUpdateDateTime
()));
24
ptimer->start(500);
25
slotUpdateDateTime
();
26
}
27
28
public
slots:
29
void
slotUpdateDateTime
()
30
{
31
QString str =
32
QDateTime::currentDateTime().toString(Qt::SystemLocaleLongDate);
33
setText(
"<H2><CENTER>"
+ str +
"</CENTER></H2>"
);
34
}
35
};
Clock
Definition:
Clock.h:16
Clock::Clock
Clock(QWidget *pwgt=0)
Definition:
Clock.h:20
Clock::slotUpdateDateTime
void slotUpdateDateTime()
Definition:
Clock.h:29
Generated by
1.8.14