Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Timer problem
Forum Update on Tuesday, May 27th 2025

Timer problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SHUBHAM SINGH RAO
    wrote on last edited by
    #1

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

    JonBJ 1 Reply Last reply
    0
    • S SHUBHAM SINGH RAO

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

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

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

      kshegunovK 1 Reply Last reply
      3
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

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

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        3
        • JonBJ JonB

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

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

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

          Read and abide by the Qt Code of Conduct

          JonBJ 1 Reply Last reply
          3
          • kshegunovK kshegunov

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

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

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

            kshegunovK 1 Reply Last reply
            0
            • JonBJ JonB

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

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by
              #6

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

              Read and abide by the Qt Code of Conduct

              JonBJ 1 Reply Last reply
              0
              • kshegunovK kshegunov

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

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @kshegunov Yes! Just what I want! :)

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved