Timer problem



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



  • @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....


  • Qt Champions 2018

    Can you be more specific? Also, a specific time lag is often a sign of bad design so is it really necessary?


  • Qt Champions 2017

    @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.



  • @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 mention SleepSimulator: 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... ;-)


  • Qt Champions 2017

    @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.



  • @kshegunov Yes! Just what I want! :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.