Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Do I need to use threading?



  • [Thread locked. Duplicate of https://forum.qt.io/topic/128611/do-i-need-to-use-threading/ --JKSH]

    I'm currently using qcustomplot (https://www.qcustomplot.com/index.php/demos/simpledemo) to plot some curves on a window, like the following,

    f83dbafb-c637-4977-989c-5542b54d02cf-image.png
    but what I'm trying to do is to change the values of the vector representing the y axis, plot them, and doing that each 1 second.
    Suppose for example that we have Qvector<int> x, as increasing integers from 0 to 250, and QVector<int> y as x², 0², 1², 2² ....etc, then each second I want to add noise to each y[i] and plot it. Therefore we wil have a noisy curve changing each second.

    In order to do that each second, I need to use the sleep() function from <unitstd.h>, but this function prevents the window from opening. Therefore I thought it's because the program is stuck 99.99 % of the time on the sleep function, maybe I need another thread that sleeps and loads the data, and another that displays the window?


Log in to reply