Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946

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:

    9cbc088f-e0a1-4fd6-837b-48817bcc03db-image.png

    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.


  • Lifetime Qt Champion

    Hi,

    setSamples likely call GUI related function which can only be done in the GUI thread.

    It does in fact not, thanks @uwer

    [edit: fixed based on @uwer's answer SGaist]



  • 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.


Log in to reply