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 not working
Forum Updated to NodeBB v4.3 + New Features

Qtimer not working

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 639 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
    satan
    wrote on last edited by
    #1

    I have two timers each for 1 sec

    QTimer Timer1, Timer2;

    connect(Timer1, SIGNAL(timeout()), this, SLOT(func1()));
    connect(Timer2, SIGNAL(timeout()), this, SLOT(func2()));

    Timer1.start(1000);
    Timer2.start(1000);

    I am seeing that when func1 is running first and func2 is called after few seconds/min. func1 stops running and only func2 is called and vice-e-verss. some times both func1 and func2 run but for a few seconds only.

    My intention is to have both the functions executed @1sec and update data in the UI.

    Please advice where I am going wrong.

    jsulmJ 1 Reply Last reply
    0
    • S satan

      I have two timers each for 1 sec

      QTimer Timer1, Timer2;

      connect(Timer1, SIGNAL(timeout()), this, SLOT(func1()));
      connect(Timer2, SIGNAL(timeout()), this, SLOT(func2()));

      Timer1.start(1000);
      Timer2.start(1000);

      I am seeing that when func1 is running first and func2 is called after few seconds/min. func1 stops running and only func2 is called and vice-e-verss. some times both func1 and func2 run but for a few seconds only.

      My intention is to have both the functions executed @1sec and update data in the UI.

      Please advice where I am going wrong.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @satan said in Qtimer not working:

      QTimer Timer1, Timer2;

      This looks like you're defining two local variables. But without more context (code) I can't say more. Also, we don't know what else you're doing (like any blocking code, stopping event loop, ...).
      You could provide a minimal reproducible example, so that others cat try to reproduce and see what is wrong.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      0
      • jsulmJ jsulm

        @satan said in Qtimer not working:

        QTimer Timer1, Timer2;

        This looks like you're defining two local variables. But without more context (code) I can't say more. Also, we don't know what else you're doing (like any blocking code, stopping event loop, ...).
        You could provide a minimal reproducible example, so that others cat try to reproduce and see what is wrong.

        S Offline
        S Offline
        satan
        wrote on last edited by
        #3

        @jsulm Both the timers are defined in the main constructor class as private. There is no blocking code/ stopping event.

        Both the functions are reading data from a HID device and func1 displays in the UI and func2 logs it into a csv file.

        jsulmJ 2 Replies Last reply
        0
        • S satan

          @jsulm Both the timers are defined in the main constructor class as private. There is no blocking code/ stopping event.

          Both the functions are reading data from a HID device and func1 displays in the UI and func2 logs it into a csv file.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @satan said in Qtimer not working:

          Both the timers are defined in the main constructor class as private

          What does this mean? Either they are defined as private class members or local variables inside constructor.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply
          0
          • jsulmJ jsulm

            @satan said in Qtimer not working:

            Both the timers are defined in the main constructor class as private

            What does this mean? Either they are defined as private class members or local variables inside constructor.

            S Offline
            S Offline
            satan
            wrote on last edited by
            #5

            @jsulm said in Qtimer not working:

            private class members

            private class members

            jsulmJ 1 Reply Last reply
            0
            • S satan

              @jsulm said in Qtimer not working:

              private class members

              private class members

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @satan Then I don't know without more code, or even better a minimal reproducible application.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • S satan

                @jsulm Both the timers are defined in the main constructor class as private. There is no blocking code/ stopping event.

                Both the functions are reading data from a HID device and func1 displays in the UI and func2 logs it into a csv file.

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @satan said in Qtimer not working:

                Both the functions are reading data from a HID device

                Could it be that this reading is blocking?

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                S 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @satan said in Qtimer not working:

                  Both the functions are reading data from a HID device

                  Could it be that this reading is blocking?

                  S Offline
                  S Offline
                  satan
                  wrote on last edited by
                  #8

                  @jsulm
                  I did some change w.r.t timer duration
                  timer1 changed to 5sec, timer2 is 1sec

                  Checked on USB data logger.
                  Func1() is called every 5sec when trigerred
                  Func2() is called every 1 sec when trigerred
                  When both are requested, only one of them is called. My point is on the USB data logger, the command to read is sent out only once.

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

                    Hi,

                    As @jsulm wrote, without more code it's not possible to understand what is going on. You might be doing stuff in the slots that could explain the issue.

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

                    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