When you close console application in Windows 10, in the following code, Boo object is not being destructed even it is a local variable. I tried to catch interrupts but it didnt worked. I tried to connect to aboutToQuit signal , it didn't worked as well. Is there any way to destruct an object just before quit?
class Boo {
public:
~Boo() {
std::cout << "i'm dying" << std::endl;
}
};
void handle_quit() {
std::cout << "I quit" << std::endl;
}
int main(int argc, char *argv[])
{
Boo test;
QCoreApplication app(argc, argv);
QTimer::singleShot(0, &app, [&]() {
std::cout << "hello world qt";
});
QObject::connect(&app, &QCoreApplication::aboutToQuit, [&]() {
handle_quit();
});
return app.exec();
}