I'm trying to add child widgets to a widget in Qt5. The problem is that the parent widget renders content which is not known to Qt and therefore transparency doesn't work correctly.
To fix this, I need to use a custom QPainter to render the widgets.
In Qt4 I could do this by using the attribute WA_PaintOutsidePaintEvent and rendering the widget in another method.
However, in Qt5 this attribute is gone.
What I've tried:
- Create a QWidget and override the paintEvent method.
- Didn't really work (didn't draw anything) but maybe it was only a small mistake. As far as I understood it, this event also doesn't keep the widget from doing its own rendering which is what I want to prevent.
- Create a QGraphicsView and a QGraphicsScene and add the widgets to the QGraphicsScene
- Draws the widgets and transparency works. Events (mouse & keyboard), however, do not work.
QWidget *widget = new QWidget(the_3d_render_widget)
does add the widget to the tree as one would expect but if you'd now set the background to transparent usingwidget->setAttribute(Qt::WA_TranslucentBackground)
the background of the widget will show what is below the Qt application rather than the content of the 3d widget. – Stefan Fabian