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 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
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on 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 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
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on 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 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.

            mrjjM 1 Reply Last reply
            0
            • A Ayush Gupta

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

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on 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 last edited by
                #7

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

                aha_1980A 1 Reply Last reply
                0
                • A Ayush Gupta

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

                  aha_1980A Offline
                  aha_1980A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on 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 last edited by
                    #9

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

                    aha_1980A 1 Reply Last reply
                    0
                    • A Ayush Gupta

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

                      aha_1980A Offline
                      aha_1980A Offline
                      aha_1980
                      Lifetime Qt Champion
                      wrote on last edited by aha_1980
                      #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