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 int main(int argc, char** argv)
15 {
16  QApplication app(argc, argv);
17  QGraphicsScene scene(QRectF(0, 0, 400, 400));
18  QGraphicsView view(&scene);
19 
20  QPushButton cmd("Quit");
21  QGraphicsProxyWidget* pproxyWidget = scene.addWidget(&cmd);
22  QTransform transform = pproxyWidget->transform();
23 
24  transform.translate(100, 350);
25  transform.rotate(-45, Qt::YAxis);
26  transform.scale(8, 2);
27  pproxyWidget->setTransform(transform);
28  QObject::connect(&cmd, SIGNAL(clicked()), &app, SLOT(quit()));
29 
30  QDial dia;
31  dia.setNotchesVisible(true);
32  pproxyWidget = scene.addWidget(&dia);
33  transform = pproxyWidget->transform();
34 
35  transform.scale(4, 2);
36  transform.rotate(-45, Qt::YAxis);
37  pproxyWidget->setTransform(transform);
38 
39  QProgressBar prb;
40  prb.setFixedSize(500, 40);
41  pproxyWidget = scene.addWidget(&prb);
42  transform = pproxyWidget->transform();
43 
44  transform.translate(20, 200);
45  transform.scale(2, 2);
46  transform.rotate(80, Qt::YAxis);
47  transform.rotate(30, Qt::XAxis);
48  pproxyWidget->setTransform(transform);
49 
50  QObject::connect(&dia, SIGNAL(valueChanged(int)),
51  &prb, SLOT(setValue(int))
52  );
53 
54  view.rotate(15);
55  view.resize(500, 500);
56  view.show();
57 
58  app.setStyle("Windows");
59 
60  return app.exec();
61 }
int main(int argc, char **argv)
Definition: main.cpp:15