From 165842b1fdfa195acc7e9900409192b99f1d2717 Mon Sep 17 00:00:00 2001 From: Denes Matetelki Date: Wed, 22 Jun 2011 16:29:57 +0200 Subject: [PATCH] Main window's close event is cought and handled due to content change --- mainwindow.cpp | 5 +++++ mainwindow.h | 3 +++ 2 files changed, 8 insertions(+) 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);