Make a dummy centralWidget so that the size and position of the other widgets can be obtained during the onClose event. No need to “show()” the mainWindow anymore in main().