PDA

View Full Version : Problem with closing the application



macbeth
27th May 2008, 14:58
Hello, I have a very odd problem.
During the start-up of my application, I do some checks to see whether the plugins were loaded properly, etc. All these checks happen in the constructor of the MainWindow (descendant of QMainWindow) and when some of them fails, I want to close the application. However, using QApplication::close(), close(), qApp->quit() or destroy() has no effect (or, at least it does not close the application, I am not aware of any other side-effects), the MainWindow shows up (and later my application crashes because it assumes the plugins are already loaded).

My closeEvent() is reimplemented,

void MainWindow::closeEvent(QCloseEvent *event){
workspace->closeAllWindows();
if (activeWindow()) {
event->ignore();
} else {
event->accept();
}
}
but I think that the problem is elswhere, because I checked that the event->accept() line is called.

Do you have any ideas how to close the application?

Thanks...

vycke
27th May 2008, 15:02
You might want to move the checks outside of the constructor & call them before your exec() (or show() or whatever). If you move the checks to a "bool MainWindow::checkPlugins()" call, you can then check the return value and either bring up the main window or exit the application.

Vycke