One solution for what you want is,
Make the window/widget to modality, such that users cannot able to close the mainwindow until you close the other.
Check Qt::WindowModality.
And also,
I have implemented in my application, when you hit,
1. double click the upper-left corner of a QMainWindow, or
2. left click the upper-left corner of a QMainWindow, then select Close()
It calls closeEvent(...). you need to relook into its implementation.
Bookmarks