Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Fullscreen and transparent window on MacOS



  • Hello community!

    The problem I am trying to solve is to make a sort of screen recorder / screencast program. For that I am creating a window to select a rectangular area which should be recorded. I wanted to solve it solved like this: I create a fully transparent fullscreen window in order to paint on the whole screen (for the rectangle that I drag with the mouse) and receive mouse signals. Unfortunately when I make a window and initialize it like this

    setWindowState(windowState() | Qt::WindowFullScreen);
    setWindowOpacity(0);
    

    the background is lost, it just gets black. I've tried to change all sorts of flags, but nothing solved the problem. It works if I exchange it to

        setWindowState(windowState() | Qt::WindowMaximized);
        setWindowOpacity(0);
    

    but it's a bad solution, because I cannot record the menu bar in MacOS, which I need to do.

    So my question: Is there any way to

    • Grab all mouse events on the screen
    • with simultaneously being able to paint on the whole screen?


  • @gladamyran said in Fullscreen and transparent window on MacOS:

    Try to call showFullScreen() instead of of setting Qt::WindowFullScreen attribute.



  • I tried that, it is the same result.



  • All right, I understand what you mean by black background :)
    Unfortunatly, it's the default background.

    One possible workaround could be to take a snapshoot of the all desktop screen and draw this image as the background of the full screen window.

    btw, I don't know of multiplaform way to do this snapshoot ...
    I don't think Qt can do that.



  • I am actually not concerned with a cross platform solution, although it would be nice.
    It is a good idea taking a screenshot. It is a dirty solution, however, because of the flickering when I change to the window and the animation when I close the window.

    I guess for better results I would have to dig deeper into how to build GUI on MacOS in general.

    Thanks, anyway!


Log in to reply