[SOLVED]QTimer queries



  • I am able to run Qtimer but have some basic doubts --

    In mainwindow.c file
    @
    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QTimer>

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    UpdtScr = new QTimer();
    UpdtScr->start(200);
    connect(UpdtScr,SIGNAL(timeout()),this,SLOT(UpdtScrn()));
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::UpdtScrn()
    {
    int i;
    i++;
    qDebug()<<i;
    }

    @

    In mainwindow.h file

    @
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>
    #include <QTimer>

    namespace Ui {
    class MainWindow;
    }

    class QTimer;
    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    QTimer *UpdtScr;
    

    public slots:
    void UpdtScrn();

    private:
    Ui::MainWindow *ui;

    };
    #endif // MAINWINDOW_H

    @

    In mainwindow.h I have declare;

    @
    QTimer *UpdtScr;
    @
    Could I declare @QTimer UpdtScr; @
    so what will be declaration in mainwindow .c
    @
    UpdtScr = new QTimer();
    //It not working ;
    connect(UpdtScr,SIGNAL(timeout()),this,SLOT(UpdtScrn()));
    //Is also having some problem pls.
    @

    Pls clearify I will be thankful to you

    Praveen



  • Thanks I have gone through the concept and really worked for Me Thanks Alot


  • Moderators

    I'm glad to hear that. Happy further coding!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.