Render Visual Subtree to QImage

  • Hey,

    First of all, some background:
    I'm working on overlaying a Qt widget on top of a widget that does 3D rendering using the OGRE 3D library.
    Unfortunately, that means that I can't simply add the widgets as children to the 3D rendering widget because setting the background to transparent won't work this way.
    Qt can't access the pixel information from the 3D library, so, setting the background to transparent will only show what's below the Qt Application rather than the content of the 3D widget.
    In Qt4 I could solve this by using the PaintOutsidePaintEvent attribute and rendering the widget into an image that I could put on top of the 3D scene using methods provided by OGRE.

    Now, my problem is that I have to transition to Qt5 and the attribute mentioned above doesn't exist anymore.
    How can I render a QWidget including its subtree in a QImage while preserving keyboard and mouse interaction in Qt5?

    Thanks in advance!

    Edit: In case that it matters, I'm on Ubuntu 16.04 and it only has to work on linux.

  • Since posting this I made some progress.
    I am able to render content and I think I can make mouse and keyboard interaction work if I flesh out what is currently just experimentation.
    However, the widget for some reason fills the widgets area with a black background.
    Any idea how I can prevent that and instead keep the background transparent?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.