Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <QWidget>
- #include <QLabel>
- #include <QPushButton>
- #include <QGridLayout>
- #include <QLineEdit>
- #include <QApplication>
- #include "proc.h"
- int main(int argc, char** argv)
- {
- QApplication app(argc, argv);
- QWidget wgt_1;
- QWidget wgt_2;
- Proc obj;
- QLabel* lbl_1 = new QLabel("Input value");
- QLabel* lbl_2 = new QLabel("Results:");
- QLabel* lbl_3 = new QLabel();
- QLabel* lbl_4 = new QLabel();
- QLabel* lbl_5 = new QLabel("Z1=");
- QLabel* lbl_6 = new QLabel("Z2=");
- QLabel* lbl_7 = new QLabel("A=");
- QLineEdit* lEd_1 = new QLineEdit;
- QPushButton* pBt_1 = new QPushButton("calculate");
- QPushButton* pBt_2 = new QPushButton("to start");
- QPushButton* pBt_3 = new QPushButton("close");
- QGridLayout* grLay_1 = new QGridLayout;
- QGridLayout* grLay_2 = new QGridLayout;
- grLay_1->setMargin(5);
- grLay_1->setSpacing(10);
- grLay_2->setMargin(5);
- grLay_2->setSpacing(10);
- lEd_1->setFixedWidth(40);
- lEd_1->setMaxLength(5);
- grLay_1->addWidget(lbl_1, 0, 0);
- grLay_1->addWidget(lbl_7, 1, 0);
- grLay_1->addWidget(lEd_1, 1, 1);
- grLay_1->addWidget(pBt_1, 2, 0);
- grLay_2->addWidget(lbl_2, 0, 0);
- grLay_2->addWidget(lbl_5, 1, 0);
- grLay_2->addWidget(lbl_3, 1, 1);
- grLay_2->addWidget(lbl_6, 2, 0);
- grLay_2->addWidget(lbl_4, 2, 1);
- grLay_2->addWidget(pBt_2, 3, 0);
- grLay_2->addWidget(pBt_3, 3, 1);
- wgt_1.setMinimumWidth(150);
- wgt_1.setWindowTitle("Input window");
- wgt_2.setMinimumWidth(220);
- wgt_2.setWindowTitle("Output window");
- QObject::connect(lEd_1, SIGNAL(textChanged(QString)),
- &obj, SLOT(SetVal(QString)));
- QObject::connect(pBt_1, SIGNAL(clicked()),
- &obj, SLOT(Run_1()));
- QObject::connect(pBt_1, SIGNAL(clicked()),
- &obj, SLOT(Run_2()));
- QObject::connect(pBt_1, SIGNAL(clicked()),
- &obj, SLOT(Print_1()));
- QObject::connect(pBt_1, SIGNAL(clicked()),
- &obj, SLOT(Print_2()));
- QObject::connect(pBt_1, SIGNAL(clicked()),
- &wgt_1, SLOT(hide()));
- QObject::connect(pBt_2, SIGNAL(clicked()),
- &wgt_1, SLOT(show()));
- QObject::connect(pBt_2, SIGNAL(clicked()),
- &wgt_2, SLOT(hide()));
- QObject::connect(pBt_3, SIGNAL(clicked()),
- &app, SLOT(quit()));
- QObject::connect(pBt_1, SIGNAL(clicked()),
- &wgt_2, SLOT(show()));
- QObject::connect(&obj, SIGNAL(ResOut_1(QString)),
- lbl_3, SLOT(setText(QString)));
- QObject::connect(&obj, SIGNAL(ResOut_2(QString)),
- lbl_4, SLOT(setText(QString)));
- wgt_1.setLayout(grLay_1);
- wgt_2.setLayout(grLay_2);
- wgt_1.show();
- return app.exec();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement