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 
13 // ----------------------------------------------------------------------
14 void loadModules(QSplashScreen* psplash)
15 {
16  QTime time;
17  time.start();
18 
19  for (int i = 0; i < 100; ) {
20  if (time.elapsed() > 40) {
21  time.start();
22  ++i;
23  }
24  psplash->showMessage("Loading modules: "
25  + QString::number(i) + "%",
26  Qt::AlignHCenter | Qt::AlignBottom,
27  Qt::white
28  );
29  qApp->processEvents();
30  }
31 }
32 
33 // ----------------------------------------------------------------------
34 int main (int argc, char** argv)
35 {
36  QApplication app(argc, argv);
37  QSplashScreen splash(QPixmap(":/splash.png"));
38 
39  splash.show();
40 
41  QLabel lbl("<H1><CENTER>My Application<BR>"
42  "Is Ready!</CENTER></H1>"
43  );
44 
45  loadModules(&splash);
46 
47  splash.finish(&lbl);
48 
49  lbl.resize(250, 250);
50  lbl.show();
51 
52  return app.exec();
53 }
QLabel * lbl(const QPainter::CompositionMode &mode)
Definition: main.cpp:14
void loadModules(QSplashScreen *psplash)
Definition: main.cpp:14
int main(int argc, char **argv)
Definition: main.cpp:15