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
I want to show the dialog before closing the program in Qt whether the
Share
If your application uses QMainWindow, overload the
closeEvent()to show the dialog and only callQMainWindow::closeEventif the user clicked ok in your dialog.If your application uses a QDialog, overload the
accept()slot and only callQDialog::acceptif the user clicked ok in your dialog.