Search code examples
qtwindowsizefullscreen

Qt: "normal" window size lost when switching to maximized state and then to fullscreen


I have an Qt application that can be displayed either "normal" (a normal window that's neither maximized nor minimized), maximized or fullscreen. I achieve that by calling the functions QWidget::showNormal(), QWidget::showMaximized() and QWidget::showFullscreen().

Let me first of all explain what does work:

  1. Going from normal to maximized and back works. Qt remembers the window size and position of the normal window and then restores that when exiting the maximized state.
  2. Going from normal to fullscreen and back works. Also here the size and position of the normal window is maintained.

What doesn't work?

When going from normal to maximized, then to fullscreen, back to maximized and then back to normal that does not work as expected. The window will not be resized to the size that it had originally, before maximizing. Instead the window will be as large as the screen (basically as large as the OS allows the window to be).

If I now go to fullscreen again then in the right upper corner and on the bottom edge there are weird artifacts that seem to look like parts of an old Vista window frame with visual effects disabled.

Here is an image that should illustrate the process I just explained:

enter image description here

I tried to save the last size of the window using QWidget::saveGeometry() or just saving the size obtained by QWidget::size() when a window state change event occured, but there were always cases when it behaved strangely. Apart from that, that last step when going full screen again looks like a bug to me.

What do you think?

UPDATE:

If I resize the window manually (to an arbitrary size) before the last step (which is going to fullscreen again), the fullscreen works without problems.


Solution

  • The new Qt 5.6 release apparently fixed that bug.