diff --git a/mainwindow.cpp b/mainwindow.cpp index 0b8060e..5442d52 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -296,6 +296,11 @@ void MainWindow::about() msgBox.exec(); } +void MainWindow::closeEvent(QCloseEvent * event) +{ + m_contentChanged && !closeFile() ? event->ignore() : event->accept(); +} + void MainWindow::setTitle(const QString &title) { if (title.isEmpty()) diff --git a/mainwindow.h b/mainwindow.h index 63adf7e..319ad74 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -35,6 +35,9 @@ public slots: void keys(); void about(); +protected: + void closeEvent(QCloseEvent * event); + private: void setTitle(const QString &title);