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  QWidget wgt;
18 
19  QWidget* pwgt1 = new QWidget(&wgt);
20  QPalette pal1;
21  pal1.setColor(pwgt1->backgroundRole(), Qt::blue);
22  pwgt1->setPalette(pal1);
23  pwgt1->resize(100, 100);
24  pwgt1->move(25, 25);
25  pwgt1->setAutoFillBackground(true);
26 
27  QWidget* pwgt2 = new QWidget(&wgt);
28  QPalette pal2;
29  pal2.setBrush(pwgt2->backgroundRole(), QBrush(QPixmap(":/stone.jpg")));
30  pwgt2->setPalette(pal2);
31  pwgt2->resize(100, 100);
32  pwgt2->move(75, 75);
33  pwgt2->setAutoFillBackground(true);
34 
35  wgt.resize(200, 200);
36  wgt.show();
37 
38  return app.exec();
39 }
int main(int argc, char **argv)
Definition: main.cpp:15