Important: Please read the Qt Code of Conduct -

[SOLVED] QTimer in mainwindow class

  • 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()));

    Thanks for your time,


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


Log in to reply