QCustomPlot Discussion and Comments

Timer delay after stoppingReturn to overview

Hello together,

im going to be brief. I have a timers which start when a user presses a "on" button:

void Controller::setupTimer(){

If the user presses the "off" button the timer stops:

void Controller::stopTimer(){

The Timer triggers every 0ms the timeout()-Signals and following slot :

 connect(&dataTimer, SIGNAL(timeout()), this, SLOT(readData()));

The "readData()"- Slot is meant to read data from my Arduino, where heartRate Sensor is placed:

void Datamodel::readData(QSerialPort *ard){
    if(ard->canReadLine() == true ){
        //reads the data from Arduino as one String [555, 753]
        allData = ard->readLine();

If i start the Timer, the data in "allData" is in Time. I test this by pressing on the HeartRate-Sensor and waiting till the Sensordata appears in allData. But if i stop the Timer and start it again , the sensor data delays. This Delay depends on how long and how often i stop the Timer.

What Ive tried: i created a new project with only one plot and one timer. To outclude any other performance issues. I even cleaned my Arduino and my Sensores. Nothing helped.

Anyone has a tip for me ? I appreciate you in advance. (Sorry for my poor english).

Have a nice week!

QTimers are not accurate in general. there are some settings to change the behavior a little:https://doc.qt.io/qt-5/qt.html#TimerType-enum

every time you start a timer, it has to deal with the event loop, which does change the timing a little bit as well even if you have it set to Precise (default is coarse)

Is there a reason you arent using onReadyRead from the serial port?