0

I have a GUI thread where the QOpenGLWidget object is created. I use another thread to process data and generate RGBA values for an image.

I cannot call the QOpenGLWidget object in the data processing thread.

How can I send data from the data processing thread to the QOpenGLWidget object?

(The data processing thread is created using boost, so I cannot use moveToThread() which requires QThread)

kevin lee
  • 13
  • 6
  • 1
    you can send a signal across threads (remember to use Qt::QueuedConnection) and pass the data as a parameter – perivesta Apr 13 '22 at 17:21
  • Check my answer for a similar question: https://stackoverflow.com/questions/71882718/errors-whan-using-qtimer-in-a-multithreading-application/71972431#71972431. – Alexander Dyagilev Apr 22 '22 at 17:24

1 Answers1

-1

Dont use QThread and signal slot for "realtime" data communication, it is leaky. You should use SafeQueue architecture like this: https://codetrips.com/2020/07/26/modern-c-writing-a-thread-safe-queue/

And remember to handle queue size to avoid overflow.

Karoshi
  • 29
  • 1
  • 7
  • Sorry, but this answer makes no sense. What's 'leaky' about signals/slots? Why use `SafeQueue` and how is it really any different from using `Qt`'s own thread-safe queue -- the event queue? – G.M. Apr 15 '22 at 07:48