Broken QWidget window states and geometries
-
Hi.
I wonder if QWidget window states are actualy broken or am I doing it wrong.
The problem:
- Create QWidget window.
- Maximize it.
- Make it full screen.
- Return back from full screen.
You will see, that window does not get back in maximized state and has geometry that differs from its geometry before maximization. That mean, that:
- Window state is not preserved upon going to full screen.
- Normal state window geometry is not preserved.
I've overriden showFullScreen slot in order to be able to preserve window state while going to full screen and back, and it works fine. However, the problem with window geometry remains. I've added some debug output in different events (resize, show, move) and found out that normalGeometry property does not hold what I expected.
According to documentation normal geometry property holds the geometry of the widget as it will appear when shown as a normal (not maximized or full screen) top-level widget. Probably I miss understand this, but I thought that normal state window geometry is stored here and remains unchanged while going maximized. However it seems like the following actions are performed while making window maximized:
- Set geometry to the value of maximized widget geometry.
- Make window maximized.
That means that window normal state geometry is changed. However it is still stored somewhere as window gets its geometry while returning to normal state from maximized state.
The behaviour described was detected on Windows 10 with Qt 5.5.1 for MSVC 2010 x86. If someone can reproduce this behaviour then a bug report should be created. If someone can explain what am I doing wrong, that please tell me)
UPD.1:
Here is example project to test described behaviour. Fullscreen mode is toggled using your system full screen key sequence . -
Hi,
I tested your code on Ubuntu 14.04, with Unity, using Qt 5.3.1.
First, when I replace your QMainWindowExtended with a QMainWindow (or a QWidget), I can't make it full screen. I think that my OS needs some extra code to handle full screen.
Then, when I use your QMainWindowExtended, everything works fine, even the geometry:- Resize widnow
- Move window
- Make it full screen
- Return back from full screen
The window is at the previous location with the previous size.
So I think that either your OS is doing its own job and Qt is not able to make it doing right, or it's a bug in Qt not making your OS working right.
-
Thank you for your effor)
The reason that it did not work with QMainWindow or QWidget is that those classes does not implement fullScreen as full featured property - it can not be set with setFullScreen() slot.
I've tested it in Open Suse (KDE) with Qt Creator as test program - yep, that's possible - and found out that every thing works fine. However test in Windows 7 (on wirtual machine) have shown the same results as described in initial post.
Considering you test results with Ubuntu and Unity it seems like a Windows-specific bug. So I'll try to go and create bug report for it.
Thanks alot)
-
@Wilk said:
The reason that it did not work with QMainWindow or QWidget is that those classes does not implement fullScreen as full featured property - it can not be set with setFullScreen() slot.
I see, thanks for the precision.
@Wilk said:
Thanks alot
No problem, I hope your bug report will be helpful for other people.