Guest User

Untitled

a guest
Dec 26th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <QApplication>
  2. #include <QWidget>
  3. #include <QPushButton>
  4. #include <QLabel>
  5. #include <QTextStream>
  6.  
  7. class App
  8. {
  9.   int state = 0;
  10.  
  11.   public:
  12.     App(int state) : state(state)
  13.     {
  14.     }
  15.  
  16.     void increment()
  17.     {
  18.       this->state++;
  19.     }
  20.  
  21.     int getState()
  22.     {
  23.       return this->state;
  24.     }
  25. };
  26.  
  27. int main(int argc, char *argv[])
  28. {
  29.   App appLogic(0);
  30.  
  31.  
  32.   QApplication appPresentation(argc, argv);
  33.  
  34.   QWidget window;
  35.  
  36.   QPushButton *btn = new QPushButton("Increment", &window);
  37.   btn->setGeometry(10, 10, 200, 50);
  38.  
  39.   QLabel *label = new QLabel(QString::number(appLogic.getState()), &window);
  40.   label->setGeometry(10, 60, 100, 100);
  41.  
  42.   window.resize(640, 480);
  43.   window.show();
  44.  
  45.   return appPresentation.exec();
  46. }
Advertisement
Add Comment
Please, Sign In to add comment