QwtPlot set curve samples error
-
Hello,
I am creating a graph with Qwt and I have a problem when I refresh the curve data with setSamples () function. I have the following error:The setSamples() function runs on a QFutureWatcher to avoid interface slow down by the processing of data to be plotted.
If I comment setSamples() the error does not occur. -
Thank you very much!
I have changed the code so that when I finish the QFutureWatcher sends a signal to a GUI thread slot. This slot updates the data with setSamples () and makes the graph replot. I didn't get the error again.In other occasions I have done it directly from the QFuture and I haven't received any error but knowing that the setSamples() is related to GUI and not only updates series data it is better to do it from the GUI thread.
-
@zedhzelgc said in QwtPlot set curve samples error:
Thank you very much!
I have changed the code so that when I finish the QFutureWatcher sends a signal to a GUI thread slot. This slot updates the data with setSamples () and makes the graph replot. I didn't get the error again.In other occasions I have done it directly from the QFuture and I haven't received any error but knowing that the setSamples() is related to GUI and not only updates series data it is better to do it from the GUI thread.
setSamples does not lead to any updates of the GUI - beside the autoReplot flag has been set.
But there might be races, when changing the samples while the update process is mapping the samples into paint device coordinates. You could derive from QwtSeriesData and add an mutex there in case concurrent access is important.