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. QTimer, start, stop and start again
Qt 6.11 is out! See what's new in the release blog

QTimer, start, stop and start again

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 3.6k 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.
  • P Offline
    P Offline
    Pippin
    wrote on last edited by
    #1

    Hello,

    I have a QTimer that repeatedly runs a function. I start it with an interval of 20 ms. Later I stop it. Then I start it again with the same interval of 20 ms. After that, I realize that the function is called twice as much as it was before I stopped the QTimer for the first time. If I stop and start it again, then the function will be called thrice as much.

    It looks like QTimer::stop doesn't do what I hoped it would. How exactly can I stop a QTimer from running a function for some time, then make it resume with the same interval ?

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

      Hi,

      Can you share the code you use to start and stop your QTimer ?

      If it's called twice as much after a single stop/start sequence, it might be that you're connecting again your QTimer object to your slot.

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

      P 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        Can you share the code you use to start and stop your QTimer ?

        If it's called twice as much after a single stop/start sequence, it might be that you're connecting again your QTimer object to your slot.

        P Offline
        P Offline
        Pippin
        wrote on last edited by
        #3

        @SGaist said:

        it might be that you're connecting again your QTimer object to your slot.

        That's exactly what I was doing! Thanks a lot, everything works perfectly now.

        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