Hi, I have a problem in using QTimer.
I'm trying to use this piece of code, but I don't know why the function "cameraTimerTimeout()" doesn't start:

mainwindow.h

Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QMainWindow>
  5. #include <QTimer>
  6. #include <iostream>
  7.  
  8. namespace Ui {
  9. class MainWindow;
  10. }
  11.  
  12. class MainWindow : public QMainWindow
  13. {
  14. Q_OBJECT
  15.  
  16. public:
  17. explicit MainWindow(QWidget *parent = 0);
  18. ~MainWindow();
  19.  
  20. private slots:
  21. void on_pushButton_clicked();
  22. void cameraTimerTimeout();
  23. void cattura();
  24.  
  25. private:
  26. Ui::MainWindow *ui;
  27. QTimer cameraTimer;
  28. };
  29.  
  30. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 

main.cpp
Qt Code:
  1. #include <QtGui/QApplication>
  2. #include "mainwindow.h"
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. QApplication a(argc, argv);
  7. MainWindow w;
  8. w.show();
  9.  
  10. return a.exec();
  11. }
To copy to clipboard, switch view to plain text mode 

mainwindow.cpp

Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3.  
  4. MainWindow::MainWindow(QWidget *parent) :
  5. QMainWindow(parent),
  6. ui(new Ui::MainWindow)
  7. {
  8. ui->setupUi(this);
  9. }
  10.  
  11. MainWindow::~MainWindow()
  12. {
  13. delete ui;
  14. }
  15.  
  16. void MainWindow::on_pushButton_clicked()
  17. {
  18. MainWindow w;
  19. ui->pushButton->setText("Ferma riconoscimento");
  20. w.cattura();
  21. }
  22.  
  23.  
  24. void MainWindow::cattura()
  25. {
  26. cameraTimer.start(33); // 33 ms = 30 fps
  27. connect(&cameraTimer, SIGNAL(timeout()),this,SLOT(cameraTimerTimeout()));
  28.  
  29. return;
  30.  
  31. }
  32.  
  33. void MainWindow::cameraTimerTimeout()
  34. {
  35. std::cout << "CIAO2" << std::endl;
  36.  
  37. }
To copy to clipboard, switch view to plain text mode 

Thank you in advance!