-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClockExample.cpp
38 lines (28 loc) · 1.05 KB
/
ClockExample.cpp
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
29
30
31
32
33
34
35
36
37
38
#include "MainWindow.h"
#include "clockthread.h"
#include <QApplication>
#include <QDebug>
#include <QObject>
int main(int argc, char *argv[])
{
QApplication clockApplication(argc, argv);
qDebug() << "main thread ID: " << clockApplication.thread()->currentThreadId();
QString newHora = QDateTime::currentDateTime().toString("hh:mm:ss");
QString newData = QDateTime::currentDateTime().toString("dd/MM/yy");
qDebug() << "newHora: " << newHora;
qDebug() << "newData: " << newData;
MainWindow windowMain;
windowMain.show();
windowMain.SetClockData(newData);
windowMain.SetClockHora(newHora);
windowMain.SetClockStyle(MainWindow::Basic);
//instantiate thread object
ClockThread clockThread;
QObject::connect(&clockThread, SIGNAL(sendHora(QString)), &windowMain, SLOT(SetClockHora(QString)), Qt::QueuedConnection);
QObject::connect(&clockThread, SIGNAL(sendData(QString)), &windowMain, SLOT(SetClockData(QString)), Qt::QueuedConnection);
clockThread.start();
clockApplication.exec();
clockThread.quit();
clockThread.wait();
return 0;
}