Exec () is actually a loop that terminates when you call quit or exit. When you click on the Close button ("X") in the window, then exit (0) is called. Therefore, the loop ends the event.
So, most likely, you have not created the main widget.
If you did, then check your code in other parts of the application. It is possible that you have formed an infinite loop somewhere.
#include <QPushButton> ... Здесь вы пишете код вашего приложения ... QPushButton btn("Temporary button", NULL); btn.show(); ... Здесь часть, где вы вызываете exec.