Advertisement
Jgug

S4.L1.Main

Feb 20th, 2013
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.88 KB | None | 0 0
  1. #include <QWidget>
  2. #include <QLabel>
  3. #include <QPushButton>
  4. #include <QGridLayout>
  5. #include <QLineEdit>
  6. #include <QApplication>
  7. #include "proc.h"
  8.  
  9. int main(int argc, char** argv)
  10. {
  11.     QApplication app(argc, argv);
  12.     QWidget wgt_1;
  13.     QWidget wgt_2;
  14.     Proc obj;
  15.  
  16.     QLabel* lbl_1 = new QLabel("Input value");
  17.     QLabel* lbl_2 = new QLabel("Results:");
  18.     QLabel* lbl_3 = new QLabel();
  19.     QLabel* lbl_4 = new QLabel();
  20.     QLabel* lbl_5 = new QLabel("Z1=");
  21.     QLabel* lbl_6 = new QLabel("Z2=");
  22.     QLabel* lbl_7 = new QLabel("A=");
  23.  
  24.     QLineEdit* lEd_1 = new QLineEdit;
  25.  
  26.     QPushButton* pBt_1 = new QPushButton("calculate");
  27.     QPushButton* pBt_2 = new QPushButton("to start");
  28.     QPushButton* pBt_3 = new QPushButton("close");
  29.  
  30.     QGridLayout* grLay_1 = new QGridLayout;
  31.     QGridLayout* grLay_2 = new QGridLayout;
  32.  
  33.     grLay_1->setMargin(5);
  34.     grLay_1->setSpacing(10);
  35.     grLay_2->setMargin(5);
  36.     grLay_2->setSpacing(10);
  37.  
  38.     lEd_1->setFixedWidth(40);
  39.     lEd_1->setMaxLength(5);
  40.  
  41.     grLay_1->addWidget(lbl_1, 0, 0);
  42.     grLay_1->addWidget(lbl_7, 1, 0);
  43.     grLay_1->addWidget(lEd_1, 1, 1);
  44.     grLay_1->addWidget(pBt_1, 2, 0);
  45.  
  46.     grLay_2->addWidget(lbl_2, 0, 0);
  47.     grLay_2->addWidget(lbl_5, 1, 0);
  48.     grLay_2->addWidget(lbl_3, 1, 1);
  49.     grLay_2->addWidget(lbl_6, 2, 0);
  50.     grLay_2->addWidget(lbl_4, 2, 1);
  51.     grLay_2->addWidget(pBt_2, 3, 0);
  52.     grLay_2->addWidget(pBt_3, 3, 1);
  53.  
  54.     wgt_1.setMinimumWidth(150);
  55.     wgt_1.setWindowTitle("Input window");
  56.  
  57.     wgt_2.setMinimumWidth(220);
  58.     wgt_2.setWindowTitle("Output window");
  59.  
  60.     QObject::connect(lEd_1,  SIGNAL(textChanged(QString)),
  61.                      &obj,   SLOT(SetVal(QString)));
  62.  
  63.     QObject::connect(pBt_1,  SIGNAL(clicked()),
  64.                      &obj,   SLOT(Run_1()));
  65.  
  66.     QObject::connect(pBt_1,  SIGNAL(clicked()),
  67.                      &obj,   SLOT(Run_2()));
  68.  
  69.     QObject::connect(pBt_1,  SIGNAL(clicked()),
  70.                      &obj,   SLOT(Print_1()));
  71.  
  72.     QObject::connect(pBt_1,  SIGNAL(clicked()),
  73.                      &obj,   SLOT(Print_2()));
  74.  
  75.     QObject::connect(pBt_1,  SIGNAL(clicked()),
  76.                      &wgt_1, SLOT(hide()));
  77.  
  78.     QObject::connect(pBt_2,  SIGNAL(clicked()),
  79.                      &wgt_1, SLOT(show()));
  80.  
  81.     QObject::connect(pBt_2,  SIGNAL(clicked()),
  82.                      &wgt_2, SLOT(hide()));
  83.  
  84.     QObject::connect(pBt_3,  SIGNAL(clicked()),
  85.                      &app,   SLOT(quit()));
  86.  
  87.     QObject::connect(pBt_1,  SIGNAL(clicked()),
  88.                      &wgt_2, SLOT(show()));
  89.  
  90.     QObject::connect(&obj,   SIGNAL(ResOut_1(QString)),
  91.                      lbl_3,  SLOT(setText(QString)));
  92.  
  93.     QObject::connect(&obj,   SIGNAL(ResOut_2(QString)),
  94.                      lbl_4,  SLOT(setText(QString)));
  95.  
  96.     wgt_1.setLayout(grLay_1);
  97.     wgt_2.setLayout(grLay_2);
  98.     wgt_1.show();
  99.  
  100.     return app.exec();
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement