I was wondering if it is possible to ignore/cancel exiting the application based of certain boolean flag is set even if the user were to click the red "X" (close window button).
I'm a c# programmer and I know it's pretty easy to do for .net applications but I'm fairly new to qt framework and searching on google did not fetch any relevant results.
Thanks,
Qt's documentation describes this specific use-case about asking permission to close in their examples.
If you subclass QMainWindow
for example and reimplement the closeEvent
function you can provide your app with customized behavior when someone tries to close it. For example:
void MainWindow::closeEvent(QCloseEvent *event)
{
if (maybeSave()) {
writeSettings();
event->accept();
} else {
event->ignore();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With