Timer problem
-
wrote on 1 Nov 2018, 13:07 last edited by
Dear sir,
At present we are trying to interface modem with raspberry pi on qt.We want to give a waiting condition(time lag ) of a definite time period , but qtimer navigates to other slot .
so please help me to implement the waiting time condition with qtimer class.Qtimer::singleshot(100,this,SLOT(update));
-
Dear sir,
At present we are trying to interface modem with raspberry pi on qt.We want to give a waiting condition(time lag ) of a definite time period , but qtimer navigates to other slot .
so please help me to implement the waiting time condition with qtimer class.Qtimer::singleshot(100,this,SLOT(update));
wrote on 1 Nov 2018, 13:20 last edited by@SHUBHAM-SINGH-RAO
You're not supposed to code "We want to give a waiting condition(time lag ) of a definite time period ", by which you mean stop and do nothing.You are supposed to code what you want to happen after the 100ms delay into your
update
slot.If you really want a delay you can use one of the methods in, say, https://stackoverflow.com/questions/3752742/how-do-i-create-a-pause-wait-function-using-qt. But don't blame us when you come back and say the interface "freezes" and it's not what you want....
-
wrote on 1 Nov 2018, 13:20 last edited by
Can you be more specific? Also, a specific time lag is often a sign of bad design so is it really necessary?
-
@SHUBHAM-SINGH-RAO
You're not supposed to code "We want to give a waiting condition(time lag ) of a definite time period ", by which you mean stop and do nothing.You are supposed to code what you want to happen after the 100ms delay into your
update
slot.If you really want a delay you can use one of the methods in, say, https://stackoverflow.com/questions/3752742/how-do-i-create-a-pause-wait-function-using-qt. But don't blame us when you come back and say the interface "freezes" and it's not what you want....
@JonB said in Timer problem:
If you really want a delay you can use one of the methods in, say, https://stackoverflow.com/questions/3752742/how-do-i-create-a-pause-wait-function-using-qt.
All those methods are pretty bad (bordering useless or even dangerous) with one exception -
SleepSimulator
. -
@JonB said in Timer problem:
If you really want a delay you can use one of the methods in, say, https://stackoverflow.com/questions/3752742/how-do-i-create-a-pause-wait-function-using-qt.
All those methods are pretty bad (bordering useless or even dangerous) with one exception -
SleepSimulator
.wrote on 1 Nov 2018, 18:53 last edited by@kshegunov
Look, I did say it wasn't the best the way to do it, but if that's what the OP wants.... It's funny you mentionSleepSimulator
: I have no recollection, but when I looked at the post I found I have previously "up-voted" that particular one! So I must have liked it best :)And I don't think the accepted answer (use native OS function), or maybe
QThread::msleep()
, is that bad. If you really don't want to do anything for a tenth of a second, just surrender your time slice and let the computer do some other more useful things. People make things so complicated these days... ;-) -
@kshegunov
Look, I did say it wasn't the best the way to do it, but if that's what the OP wants.... It's funny you mentionSleepSimulator
: I have no recollection, but when I looked at the post I found I have previously "up-voted" that particular one! So I must have liked it best :)And I don't think the accepted answer (use native OS function), or maybe
QThread::msleep()
, is that bad. If you really don't want to do anything for a tenth of a second, just surrender your time slice and let the computer do some other more useful things. People make things so complicated these days... ;-)@JonB said in Timer problem:
And I don't think the accepted answer (use native OS function), or maybe QThread::msleep(), is that bad. If you really don't want to do anything for a tenth of a second, just surrender your time slice and let the computer do some other more useful things. People make things so complicated these days... ;-)
The problem with that is that it is uninterruptable, ever.
-
@JonB said in Timer problem:
And I don't think the accepted answer (use native OS function), or maybe QThread::msleep(), is that bad. If you really don't want to do anything for a tenth of a second, just surrender your time slice and let the computer do some other more useful things. People make things so complicated these days... ;-)
The problem with that is that it is uninterruptable, ever.
wrote on 2 Nov 2018, 08:20 last edited by@kshegunov Yes! Just what I want! :)
1/7