Duplicate QGLWidget
-
Hi I'm using QGLWidget to stream the screen of a virtual machine onto a QT UI. It works fine. Now I want to have that content of the QGLWidget been duplicate onto another widget (maybe a second QGLWidget or a QGraphicsView, for example). In this second widget I want to see exactly what I see in the original QGLWidget. Is there any smart way of doing this? A simple but dump way of doing it is to take a screenshot of the QGLWidget and then copy it over to the second widget, and then do this with high frequency. But rather than doing this, I'd like to "stream" the content directly onto a second widget. Any ideas?
-
Hi,
you could share the OpenGL context between the two widgets. Then render the original graphics offscreen into a texture and use this texture for displaying the content in both widgets. -
Do you have any examples by hand showing how to do this?
-
@Anna234 No, sorry. But this example http://doc.qt.io/qt-5/qtquick-scenegraph-textureinthread-example.html contains most of what you'll need: It demonstrates how to render to an offscreen surface and how to use
setShareContext()
. Hope this helps! -
I'm using QT4.8 - I think many of these functions are only available in QT5.
-
@Anna234 In this case you may want to use the native OpenGL functions.