Nominate our 2022 Qt Champions!

Draw a widget on top af everything else

  • Hi everyone,
    I would like to draw a widget (let's call it widget A) on top of another one (widget B) (a sort of transparent bar with buttons) and that stays on top and is still attached to the main window (move with it and act like it was in a layout).
    Widget A is a QQuickWidget (but I'm not sure it's relevant here as it can also be a QWidget containing a QQuickWidget).
    The widget B which is quite complex, I haven't written it myself, and is not painted directly by qt. It's repainted frequently (like 30 times/sec) by the GPU with different context (opengl/directx/...) depending on the platform (still trying to understand how exactly it works but I can ask for detailed explanation if necessary).
    I've played with various parameters of setWindowFlags to do so but I've always been in one of three following scenarios :

    • The widget A is drawn behind the widget B so you can never see it
    • The widget A is drawn over the widget B but as soon as the widget B is redrawn, it gets over it. I can get a glimpse at the widget when resizing the window to force widgets to be redrawn but that's all. I don't think redrawing everything multiple times per second is a valuable option in term of performance.
    • The widget A is in a separate window (frameless or not) which is strictly on top of the widget B (that part is perfect, no need to redraw every so often). But as the widget is in a separate window, it doesn't stick with the main window. Like when moved on the screen, it stays in the same place.

    If you have any solution, even a dirty hack, i would be happy, because I've been stuck on that point for the last two days.