View Full Version : Share content between two QGLWidgets

15th July 2015, 08:09
Hi I have the following scenario. I've got a QGLWidget which displays contents of a VM's framebuffer in real time. This basically shows the VM's screen in fullscreen mode in my QT application. On another tab in my QT application, I want to show a sort of "preview" of this VM's framebuffer. This is implemented using another QGLWidget which is basically supposed to "stream" the contents of the first big QGLWidget, but scaled down to a fixed smaller size. E.g. the VM's screen in 1024x768 while the preview is just 400x200. (The numbers are just an example).

Now my question. What is the best way to implement this? I have seem that it is possible to pass a shareWidget parameter to a QGLWidget when constructing it, but I don't yet understand how I can access the content of the first widget from the second widget? And also, is it possible to scale down this content on the second widget without actually affecting what is drawn in the first widget? Is it maybe a better way to use overlays for this?

I cannot find any similar examples in the QT documenation.

17th July 2015, 01:51
I think it's possible to use a QGLPixelBuffer object to generate QImages that you draw as the preview window(s).

This way you wouldn't need to share the OpenGL contexts, and the widget in that other tab can be just an ordinary QWidget that draws the QImages generated.