Search code examples
pythonuser-interfaceqt5qt3dpyside2

Overlapping widgets in QLayout


I want to create a window where is Qt3DWindow in the back and some QPushButtons above it. However only Qt3DWindow animation is shown and QPushButtons are not seen. I would also like to have Qt3DWindow functional and QPushButtons as well (So I can click on the buttons or 3D animation behind). Buttons are only seen when I set Qt3DWindow transparency to lower value. Of course in that case buttons are only seen but not functional.

class MainWindow(QMainWindow):
    def __init__(self, *args):
        QMainWindow.__init__(self, *args)

        self.window = Window()  # Qt3DExtras.Qt3DWindow
        self.container = self.createWindowContainer(self.window)

        self.buttons = Buttons()
        self.layout().addWidget(self.buttons.view)  # QtWidgets.QGraphicsView
        self.layout().addWidget(self.container)

Solution

  • QWidget::createWindowContainer() will handle the geometry of the window however it does change the fact that the managed window still overlays the window that contains the widget. So any child of that widget will not be visible as it will be obscured by the Qt3DWindow.

    Only viable alternative is move the widgets you want to overlay into their own window and handles it's geometry yourself.

    Or use a Scene3D inside a QDeclarativeWidget but that will affect performance.