Wait shortly for QApplication to register the screen change before continuing.

When there’s a screen resolution change, QApplication::desktop() will continue to report the old resolution causing incorrect sizing at startup.

Now, create a QEventLoop that will process the required events during a short period of time.

(cherry picked from commit f4db08f363d2fd83a2d4f84fc33d6d20769f92ee)