QTimer not emitting timeout signal
I am running into an issue where QTimer is not emitting the timeout signal, QTimer is active and the connect method to the slot also returns true (1). I have set the interval as 3 seconds but i could see that the remainingTime() is showing garbage value e.g 79618 etc.. The QTimer is part of a QThread which is created by a Main UI Thread of my application. The caller to the QTimer is part of the same QThread so there is no problem of different thread involvement as i verified the Thread Ids.
Any kind of help is appreciated !!!
Thanks in advance !!
JonB last edited by
The advice here will be that you're going to need to show the relevant extract from the code...!
The QTimer is part of a QThread
- Is your thread running an event loop?
- Is your thread running an infinite loop?
Also make sure, that your QTimer is create on the heap and parented correctly/or moved to the corect thread manualy. QTimers on the stack life in the thread they are created on.
@JKSH Yeah, the Thread is running an infinite while loop until a flag is set to false which it is monitoring for.
Is this a reason for QTimer to show a garbage value for remainingTime() ?
If you use an infinite loop, there's no event loop running, hence the QTimer can't do its job.
Do you really need to spin a loop that fast ? What about using a Timer to check that flag on a regular basis ?
@SGaist Hello, Thanks for your reply. We are using a network stack so it has that infinite while loop running to meet the timing required for our application.
Is there any other work around or solution to make my QTimer work without making any changes to the current running loop?
you ccould use a QTime or QElapsedTimer instance and check each whileloop iteration the