문제

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();
도움이 되었습니까?

해결책 2

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

private slot:
void MyFunction();

다른 팁

Is your main loop stil running? Does the object you reference with "this" is stil existent? Could you check if the timer is set to single shot?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top