Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Do I need to use threading?
Forum Updated to NodeBB v4.3 + New Features

Do I need to use threading?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 300 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sofiane
    wrote on last edited by
    #1

    I'm currently using qcustomplot (https://www.qcustomplot.com/index.php/demos/simpledemo) to plot some curves on a window, like the following,
    664900f7-2525-4384-8e09-4f1a78f48540-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?

    1 Reply Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by JoeCFD
      #2

      you use qtimer(not sleep()) to do it. Then no thread is needed.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved