How to send data from another thread to QOpenGLWidget object in GUI thread?

118 views Asked by At

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)

1

There are 1 answers

1
Karoshi On

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.