Qt 5.10 Book Examples
main.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // main.cpp
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 #include <QtWidgets>
12 #include "MyWorker.h"
13 
14 // ----------------------------------------------------------------------
15 int main(int argc, char** argv)
16 {
17  QApplication app(argc, argv);
18  QLCDNumber lcd;
19  QThread thread;
20  MyWorker worker;
21 
22  QObject::connect(&worker, SIGNAL(valueChanged(int)),
23  &lcd, SLOT(display(int))
24  );
25 
26  lcd.setSegmentStyle(QLCDNumber::Filled);
27  lcd.display(10);
28  lcd.resize(220, 90);
29  lcd.show();
30 
31  worker.moveToThread(&thread);
32 
33  QObject::connect(&thread, SIGNAL(started()),
34  &worker, SLOT(slotDoWork())
35  );
36 
37  QObject::connect(&worker, SIGNAL(finished()),
38  &app, SLOT(quit())
39  );
40 
41  thread.start();
42 
43  int nResult = app.exec();
44 
45  thread.quit();
46  thread.wait();
47 
48  return nResult;
49 }
50 
int main(int argc, char **argv)
Definition: main.cpp:15