Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [SOLVED] QTimer in mainwindow class

    General and Desktop
    qtimer
    1
    2
    1363
    Loading More Posts
    • 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.
    • Duncan
      Duncan last edited by Duncan

      Hello!

      I'm trying to call a function in my main window class every 5 seconds, what is the best way to do this?

      I tried using QTimer, but could not get it to work. Below is what I have tried so far:

      Mainwindow.h File:

      private: QTimer *primeTime;

      Mainwindow.cpp File:

         primeTime = new QTimer(this);
            connect(primeTime, SIGNAL(timeout()), this, SLOT(timeCheck()));
            primeTime->start(1000); 
      

      Thanks for your time,

      Duncan

      1 Reply Last reply Reply Quote 0
      • Duncan
        Duncan last edited by

        Forgot to add the #include <QTimer> in the mainwindow.h file

        :)

        1 Reply Last reply Reply Quote 0
        • First post
          Last post