Use QWidget::screen instead of having own code to fetch the screen. It works better this way before the window is initialised.