your MyDialog will be placed in the center of Sample1 Widget and not the screen.

Using QDesktopWidget you can get the size of the screen and then center your MyDialog.