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  QLabel* plblDisplay = new QLabel;
20  plblDisplay->setFrameStyle(QFrame::Box | QFrame::Raised);
21  plblDisplay->setLineWidth(2);
22  plblDisplay->setFixedHeight(50);
23 
24  QLabel* plblText = new QLabel("&Text:");
25  QLineEdit* ptxt = new QLineEdit;
26  plblText->setBuddy(ptxt);
27  QObject::connect(ptxt, SIGNAL(textChanged(const QString&)),
28  plblDisplay, SLOT(setText(const QString&))
29  );
30 
31 
32  QLabel* plblPassword = new QLabel("&Password:");
33  QLineEdit* ptxtPassword = new QLineEdit;
34  plblPassword->setBuddy(ptxtPassword);
35  ptxtPassword->setEchoMode(QLineEdit::Password);
36  QObject::connect(ptxtPassword, SIGNAL(textChanged(const QString&)),
37  plblDisplay, SLOT(setText(const QString&))
38  );
39 
40  //Layout setup
41  QVBoxLayout* pvbxLayout = new QVBoxLayout;
42  pvbxLayout->addWidget(plblDisplay);
43  pvbxLayout->addWidget(plblText);
44  pvbxLayout->addWidget(ptxt);
45  pvbxLayout->addWidget(plblPassword);
46  pvbxLayout->addWidget(ptxtPassword);
47  wgt.setLayout(pvbxLayout);
48 
49  wgt.show();
50 
51  return app.exec();
52 }
int main(int argc, char **argv)
Definition: main.cpp:15