Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Brainstorm
  4. QTimer not emitting timeout signal
Forum Updated to NodeBB v4.3 + New Features

QTimer not emitting timeout signal

Scheduled Pinned Locked Moved Unsolved Brainstorm
8 Posts 5 Posters 3.2k Views 2 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.
  • C Offline
    C Offline
    Channareddy
    wrote on last edited by
    #1

    hello,
    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 !!

    JonBJ JKSHJ 2 Replies Last reply
    0
    • C Channareddy

      hello,
      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 !!

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

      @Channareddy
      The advice here will be that you're going to need to show the relevant extract from the code...!

      1 Reply Last reply
      3
      • C Channareddy

        hello,
        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 !!

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        @Channareddy said in QTimer not emitting timeout signal:

        The QTimer is part of a QThread

        1. Is your thread running an event loop?
        2. Is your thread running an infinite loop?

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        C 1 Reply Last reply
        3
        • J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          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.


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          1
          • JKSHJ JKSH

            @Channareddy said in QTimer not emitting timeout signal:

            The QTimer is part of a QThread

            1. Is your thread running an event loop?
            2. Is your thread running an infinite loop?
            C Offline
            C Offline
            Channareddy
            wrote on last edited by
            #5

            @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() ?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              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 ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              C 1 Reply Last reply
              1
              • SGaistS SGaist

                Hi,

                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 ?

                C Offline
                C Offline
                Channareddy
                wrote on last edited by
                #7

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

                J.HilkJ 1 Reply Last reply
                0
                • C Channareddy

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

                  J.HilkJ Offline
                  J.HilkJ Offline
                  J.Hilk
                  Moderators
                  wrote on last edited by
                  #8

                  @Channareddy
                  you ccould use a QTime or QElapsedTimer instance and check each whileloop iteration the elapsed value


                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  1 Reply Last reply
                  2

                  • Login

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