Qt: showMaximized () not working on Windows

I open a file in my application (on Windows ) with a double click . I am passing the filename obtained with the argument to my open logic. There I call showMaximized () but it doesn't get picked up. The window that opens is not maximized and is by default in the upper left corner of the screen.

Note that all this logic flow goes through main () and hence showMaximized () is probably called before the event loop starts. Does this mean the showMaximized () function is working correctly? If so, how to solve this?

I also tried using QTimer :: singleShot (0, ..., ...) (to start the event loop), but that even stopped the non- Max screen from starting.

PS: On Mac, the screen gets maxed out as it happens via an event ( QEvent :: FileOpen )

+3


source to share


2 answers


The simplest solution is to use size (800 600) before using showMaximized () . I have a similar error in Qt 5.7.0 on Windows 8.1.



+1


source


The first time the process calls ShowWindow, the show command is ignored and uses the command provided in the STARTUPINFO structure (which must match the nCmdShow parameter in WinMain).

http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548%28v=vs.85%29.aspx



This surprising behavior tends to manifest itself in problems like the ones you describe. You can fix this problem simply by sending the QT showMaximized call twice if you don't want to use Win32 API calls directly.

0


source







All Articles