Threaded OpenGL rendering, multiple QOpenGLWidgets with same parent
-
Hi all, I have several rendering tasks that wanna rendering in different widgets.
I have created a base rendering class that inherits from QOpenGLWidget. Every of my rendering window/widget inherits from my base render class. In my class I manually manage a QThread and move my renderer tasks (all gl functions) in to this thread and grab the context() from UI thread. And call my class's "update" function by "InvokeMethod" with QueuedConnection.
By doing this, I could render and update my render content in different thread.class GLView; class GLRenderer; GLRenderer::draw() { // move context() into QThread thread // gl function calls QMetaObject::InvokeMethod(glview_, "update"); }
These rendering widgets works perpectly, renders smoothly when they have DIFFERENT parents. However, when putting them on the same QMainWindow(as parent), one of my rendering window starts to flicker.
I have double checked that the rendering threads are different. I know parent thing in Qt may affect an object's lifetime (parent is responsible for releasing its children). But any other differences that cause my issue here? Any idea?
Platform: Qt5.6, Ubuntu16.04
Update
I simple inference would be "Event Loop". Since QueuedConnection may delay an update() call, which means my rendering task is scheduled to be delayed. It's reasonable that every individual window in Qt may have its own Event Loop. And when I attach all my rendering window on same parent, I have scheduled too many update() call which causes flickering in rendering.