I want to show the dialog before closing the program in Qt whether the user wants to cancel or save the program, i.e. by clicking on cancel the user has chance to return to program with uncleaned state, like windows paint, or notepad in which the aware dialog before closing appear alerting the users?
by the way I use Qt
If your application uses QMainWindow, overload the
closeEvent() to show the dialog and only call
QMainWindow::closeEvent if the user clicked ok in your dialog.
If your application uses a QDialog, overload the
accept() slot and only call
QDialog::accept if the user clicked ok in your dialog.