PDA

View Full Version : exit(0) does not call closeEvent



ricardo
24th June 2009, 20:27
Hi friends!

When the user closes my app (pressing window X), closeEvent tests if you want to save document, but if user uses menus, my code calls exit(0) but closeEvent is not called!

Do you know how I should close my app from menus in order to call closeEvent before exiting?

Thanks a lot for your help.

Lykurg
24th June 2009, 20:58
use QCoreApplication::quit()/QCoreApplication::exit() instead of exit(0).

ricardo
24th June 2009, 21:05
use QCoreApplication::quit()/QCoreApplication::exit() instead of exit(0).

None of them work, both bypass closeEvent. But I realised close() is what I was looking for.

Thanks anyway.

Lykurg
24th June 2009, 21:34
None of them work, both bypass closeEvent.
Right, my brain... sorry.

faldzip
25th June 2009, 08:39
just connect your exit action triggered() signal with main window's close() slot. You can even do it with Designer.