Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. QwtPlot set curve samples error
QtWS25 Last Chance

QwtPlot set curve samples error

Scheduled Pinned Locked Moved Solved 3rd Party Software
4 Posts 3 Posters 775 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.
  • Z Offline
    Z Offline
    zedhzelgc
    wrote on last edited by zedhzelgc
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by SGaist
      #2

      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]

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • Z Offline
        Z Offline
        zedhzelgc
        wrote on last edited by
        #3

        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.

        U 1 Reply Last reply
        0
        • Z zedhzelgc

          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.

          U Offline
          U Offline
          uwer
          wrote on last edited by
          #4

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

          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