Advertisement
Guest User

Untitled

a guest
Apr 5th, 2015
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include "mywidget.h"
  2. #include "ui_mywidget.h"
  3.  
  4. #include "myclass.h"
  5.  
  6. MyWidget::MyWidget(QWidget *parent) :
  7.     QWidget(parent),
  8.     ui(new Ui::MyWidget)
  9. {
  10.     ui->setupUi(this);
  11.  
  12.     m_Timer = new QTimer(this);
  13.     connect(m_Timer, SIGNAL(timeout()), this, SLOT(TimerSlot()));
  14. }
  15.  
  16. MyWidget::~MyWidget()
  17. {
  18.     delete ui;
  19. }
  20.  
  21. void MyWidget::TimerSlot()
  22. {
  23.     // As an example I want to execute a QMessageBox each second
  24.  
  25.     QMessageBox::information(nullptr, "Title", "Test");
  26. }
  27.  
  28. void MyWidget::on_pushButton_clicked()
  29. {
  30.     // Like this the code works just fine and the MessageBox is fired up each second
  31.     // m_Timer->start(1000);
  32.  
  33.     // Create an instance, the constructor will run and connect the signal and slots
  34.     // But nothing happens...
  35.  
  36.     MyClass m_Class;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement