Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]QTimer queries

[SOLVED]QTimer queries

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    praveen0991kr
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • P Offline
      P Offline
      praveen0991kr
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #3

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

        (Z(:^

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved