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 Monday, May 27th 2025

Timer problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 1.6k Views
  • 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 1 Nov 2018, 13:07 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));

    J 1 Reply Last reply 1 Nov 2018, 13:20
    0
    • S SHUBHAM SINGH RAO
      1 Nov 2018, 13:07

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

      J Offline
      J Offline
      JonB
      wrote on 1 Nov 2018, 13:20 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....

      K 1 Reply Last reply 1 Nov 2018, 16:39
      3
      • V Offline
        V Offline
        VRonin
        wrote on 1 Nov 2018, 13:20 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
        • J JonB
          1 Nov 2018, 13:20

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

          K Offline
          K Offline
          kshegunov
          Moderators
          wrote on 1 Nov 2018, 16:39 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

          J 1 Reply Last reply 1 Nov 2018, 18:53
          3
          • K kshegunov
            1 Nov 2018, 16:39

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

            J Offline
            J Offline
            JonB
            wrote on 1 Nov 2018, 18:53 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... ;-)

            K 1 Reply Last reply 1 Nov 2018, 19:57
            0
            • J JonB
              1 Nov 2018, 18:53

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

              K Offline
              K Offline
              kshegunov
              Moderators
              wrote on 1 Nov 2018, 19:57 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

              J 1 Reply Last reply 2 Nov 2018, 08:20
              0
              • K kshegunov
                1 Nov 2018, 19:57

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

                J Offline
                J Offline
                JonB
                wrote on 2 Nov 2018, 08:20 last edited by
                #7

                @kshegunov Yes! Just what I want! :)

                1 Reply Last reply
                0

                1/7

                1 Nov 2018, 13:07

                • Login

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