Search code examples
c++qtqtimer

QTimer - Repetitive Timer


I'm trying to have an QTimer object count in intervals, continuously to call a function. I followed an example and I have set the intervals but it doesn't appear to start counting ever again.

This is the piece of code I'm working with

QTimer *timer = new QTimer(this);
timer->setInterval(1000);
connect(timer, SIGNAL(timeout()), this, SLOT(MyFunction()));
timer->start();

Solution

  • sorry didn't have the function set to a slot in the header file that was the problem

    private slot:
    void MyFunction();