Unsolved How to every time check variable value?
-
@rockon209 Can't you just emit a signal each time this variable is changed? Then everyone interested to this variable can connect to this signal and do what ever needs to be done. This way there is no need to check actively at all...
-
@J-Hilk @koahnig @jsulm
I will explain again
I pressed the start button, and I start recording some values from other sensors. And suddenly the temp value is 100 degree so therefore I want to stop the application. So when I am recording the values from other sensor I should everytime keep an eye on the temp to check the value. How can i do it. One way i know is use Qtimmer and every one seconnd check the value of the Temp sensor. Is there any other way instead of this? -
This post is deleted! -
@rockon209 If you don't get the temperature already on a regular basis then you need to check it periodically using a QTimer. Alternative would be to have a thread where you read the temperature sleep for some time and read again in a loop. But using a QTimer is way easier!
-
@jsulm
if I want to use Qthread how i can do it. I havnt used thread till now so dont know how to used it. I read about it but not able to understand. -
@rockon209 Why not just use a QTimer for that?
If you really want to use multithreading for that then you should read:
https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/
http://doc.qt.io/qt-5/thread-basics.html -
@jsulm
I dont have only one sensors but many sensors are there to measure differnt data then i think it doesnt make any sense to create different timers everytime to get the data from it. Thats why i thought to use thread. -
@rockon209
There would be nothing to stop from reusing a timer. If you fear you will get too many.
If your design can work with 1 thread, then it can also work with one timer.How many sensors are we talking about?
We have a system running where it uses QTimer. I think we use around 60 most of the time and have seen
no issue so far. -
@mrjj
i am using around 10 sensors so may be i will need around 8 timers to get the data from them. I dont know which one is the optimum solution. Thats why i started the topic. But if you say that 60 timers are also working fine then i think i will go for timers -
@rockon209 how exactly to do communicate with your sensors? QIODevice, a file that is written, serial port, bluetooth, vendor specific library etc. Maby theres a prefabricated way/Signal that you can use as a notifier for new data available.
-
@rockon209 How many timers you need depends on how you read all these sensors. If you read all of them at the same frequency then one timer is enough.
-