Important: Please read the Qt Code of Conduct -

Implementing fullscreen mode - frameless window that hides the taskbar

  • I'm trying to make a true fullscreen window (not just maximized one). Experimenting on Windows for now. According to this article a window should be able to hide the taskbar, i. e. have a higher z-order. But this code


    only produces this result:
    and this message in the output:

    QWindowsWindow::setGeometryDp: Unable to set geometry 1920x1080+0+0 on QWidgetWindow/'CMainWindowWindow'. Resulting geometry: 1916x1054+0+0 (frame: 8, 30, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 568x323, maximum size: 16777215x16777215).

    How can achieve what I want? The screenshot looks great, except that the taskbar is drawn over my window, and I need it to be the other way around.

  • Try adding


  • Finally got time to return to this task.
    If I do as you suggested, the window just disappears both from screen and from the taskbar (no button, which is typical for frameless windows).

    UPDATE: Turns out, a mere showFullScreen call does the trick. What got me confused previously when I tried was that there's a ~1 second delay between the window maximizing and the taskbar disappearing.
    Now the only problem I have is how to restore the original size and position of the window. Guess I'm gonna have to use the saveGeometry / restoreGeometry methods.

  • Hi, using the following function works for me:
    void QWindow::setWindowState(Qt::WindowState state) with state Qt::WindowFullScreen.

  • That has the same effect as showFullscreen. Perhaps, the implementation is the same. I find showFullscreen much more neat.

    For restoring, I call QRect savedGeometry = geometry() before showFullscreen, and then when I need to get back to a regular window:


    Not sure if raise and activateWindow are necessary, it's just a code snippet I see in many different Qt projects that's called when window state changes. Could be a fix for some very old Qt bug that's been fixed long ago, for all I know.

  • @Violet-Giraffe Yes, it has the same effect. You said you want to restore the window's previous geometry: You can just read the current state with Qt::WindowState QWindow::windowState() const and restore it when you need to. This also automatically restores the previous geometry.

  • @Wieland said:

    This also automatically restores the previous geometry.

    That's neat! setWindowState(windowState() & ~Qt::WindowFullScreen) works like charm (at least on Windows 7), no need for any additional member variables.

  • Moderators

    Also note there's a showNormal()method that does the same as tinkering with windows states.
    There are basically 4 methods for setting the state: showNormal(), showMaximized(), showMinimized() and showFullScreen(). They might be more convenient than tracking the state flags, depending on your need.

  • showNormal alone doesn't restore the original geometry, it just exits the full screen mode.

  • Moderators

    That's... weird. The implementation is basically the same, i.e.

    void QWidget::showNormal()
       setWindowState(windowState() & ~(Qt::WindowMinimized | Qt::WindowMaximized | Qt::WindowFullScreen));

    I wonder if that's some bug then?

  • Re-checked and confirmed: showNormal works properly in conjunction with showFullScreen.

Log in to reply