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. How we can implement our own timer in QT
Forum Updated to NodeBB v4.3 + New Features

How we can implement our own timer in QT

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 3 Posters 1.2k 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.
  • A Offline
    A Offline
    Ayush Gupta
    wrote on 27 Dec 2018, 06:47 last edited by
    #1

    I have one normal application which will send the time of its environment continously to my QT application.. I want to create a timer which will read the update time (current value) which is updated continously by normal C/C++ application. Currently I tried overloading start/stop of QTimer but it act as blocker and not execute parallely and not able to get the updated time from my C/C++ application

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 27 Dec 2018, 06:58 last edited by
      #2

      Hi
      How do you read the "time" from the " normal C/C++ application" ?

      1 Reply Last reply
      1
      • A Offline
        A Offline
        Ayush Gupta
        wrote on 27 Dec 2018, 07:03 last edited by
        #3

        @mrjj I have qt application as an dll I will update the time in qt application using my normal application using dll interface in static variable of class..That dll interface is called continously in thread using my normal application

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 27 Dec 2018, 07:23 last edited by
          #4

          Hi
          Ok, so Qt runs in a DLL.
          Are you running an event loop ?
          Normally QTimer is not blocking but uses the event queue to sent the timeout signal.
          But it sounds like Qt event loop is not running.

          Can you use signal and slot inside the Qt dll ?

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Ayush Gupta
            wrote on 27 Dec 2018, 07:29 last edited by
            #5

            @mrjj Yes I can use signal and slot inside the Qt dll..
            My requirement is I am getting updated time from my normal C/C++ application regularly. So I need to implement a non blocking timer which will start and stop at particular time.

            Say g_time I recived from my normal C/C++ application when I start my timer and I need to stop the timer when the time recieved from my application to QT dll passes 5 seconds. Please note that it should be the time passed 5 seconds from the time recived from normal C/C++ application not my time of QT dll application.

            M 1 Reply Last reply 27 Dec 2018, 07:49
            0
            • A Ayush Gupta
              27 Dec 2018, 07:29

              @mrjj Yes I can use signal and slot inside the Qt dll..
              My requirement is I am getting updated time from my normal C/C++ application regularly. So I need to implement a non blocking timer which will start and stop at particular time.

              Say g_time I recived from my normal C/C++ application when I start my timer and I need to stop the timer when the time recieved from my application to QT dll passes 5 seconds. Please note that it should be the time passed 5 seconds from the time recived from normal C/C++ application not my time of QT dll application.

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 27 Dec 2018, 07:49 last edited by
              #6

              @Ayush-Gupta
              Hi
              Im not sure how the QTimer blocks. (normally it doesn't )
              However, it sounds like
              https://doc.qt.io/qt-5.11/qdeadlinetimer.html
              could be used ?

              1 Reply Last reply
              3
              • A Offline
                A Offline
                Ayush Gupta
                wrote on 4 Jan 2019, 05:30 last edited by
                #7

                @mrjj QTDeadline Timer did not helped me..Since I am dependent on time based on my normal c++ application.

                A 1 Reply Last reply 4 Jan 2019, 05:55
                0
                • A Ayush Gupta
                  4 Jan 2019, 05:30

                  @mrjj QTDeadline Timer did not helped me..Since I am dependent on time based on my normal c++ application.

                  A Offline
                  A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on 4 Jan 2019, 05:55 last edited by
                  #8

                  @Ayush-Gupta why do you need a timer at all?

                  You said you are already getting times, so you just need to calculate time2 - time1, right?

                  Qt has to stay free or it will die.

                  1 Reply Last reply
                  4
                  • A Offline
                    A Offline
                    Ayush Gupta
                    wrote on 7 Jan 2019, 06:19 last edited by
                    #9

                    @aha_1980 sorry I do not understand your answer..Can you please explain

                    A 1 Reply Last reply 7 Jan 2019, 06:53
                    0
                    • A Ayush Gupta
                      7 Jan 2019, 06:19

                      @aha_1980 sorry I do not understand your answer..Can you please explain

                      A Offline
                      A Offline
                      aha_1980
                      Lifetime Qt Champion
                      wrote on 7 Jan 2019, 06:53 last edited by aha_1980 1 Jul 2019, 06:53
                      #10

                      @Ayush-Gupta

                      Say g_time I recived from my normal C/C++ application

                      when the time recieved from my application to QT dll passes 5 seconds.

                      You receive the time from your C++ application, why not just substract the two times and you're done?

                      Qt has to stay free or it will die.

                      1 Reply Last reply
                      3

                      • Login

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