I am trying to use the QCloseEvent
to close all my dialogs and quit the application when the main window closes. I have read the documentation and looked at many examples and this is what I've come up with so far:
In my .h file:
protected:
void mainwindow::closeEvent(QCloseEvent * );
In my mainwindow.cpp file:
class QCloseEvent;
void mainwindow::closeEvent(QCloseEvent *event)
{
event->accept();
if (event->isAccepted())
{
QApplication::quit();
}
}
when I run this code I get the following errors:
mainwindow::closeEvent'
: local function definitions are illegal
mainwindow.cpp(13): this line contains a '{' which has not yet been matched