Qtimer not working
-
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.
-
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.
@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. -
@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. -
@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.
@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.
-
@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.
-
-
@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.
@satan said in Qtimer not working:
Both the functions are reading data from a HID device
Could it be that this reading is blocking?
-
@satan said in Qtimer not working:
Both the functions are reading data from a HID device
Could it be that this reading is blocking?
@jsulm
I did some change w.r.t timer duration
timer1 changed to 5sec, timer2 is 1secChecked 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.