QWidget::show() is a non-blocking method. Your main window object goes out of scope immediately.