Unsolved How we can implement our own timer in QT
-
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
-
Hi
How do you read the "time" from the " normal C/C++ application" ? -
@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
-
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 ?
-
@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.
-
@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 ? -
@mrjj QTDeadline Timer did not helped me..Since I am dependent on time based on my normal c++ application.
-
@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? -
@aha_1980 sorry I do not understand your answer..Can you please explain
-
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?