I’d like to do some house keeping stuff (like writing to a file etc) in a Qt app before the app exits. How can I get to this function (exit or whatever is called) in Qt?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to connect a slot with the clean up code to the
QCoreApplication::aboutToQuit()signal.This allows you to delete QObjects with
QObject::deleteLater()and the objects will be deleted as you have not yet left the main application event loop.If you are using a C library that requires a ‘shutdown’ call you can normally do that after the return from
QCoreApplication::exec().Example for both techniques: