The problem is as follows: if the application is closed while it's not actively doing anything, it exits correctly. If it's actively working on something (waiting in a while loop, for example), however, the main window will close but the program will continue to run in the background, as confirmed by opening the task manager.
I've spent a good part of today googling the problem and implementing possible fixes, but to no avail. It seems like the quit() function simply doesn't do anything. Here are some things that I've tried:
app.connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
. I know the signal is triggered, because I tried changing &app, SLOT(quit())
to qApp, SLOT(aboutQt())
and the aboutQt window briefly popped up.qApp->quit();
at the beginning of a function that runs from a main window button. The application does run to that line, but it has no effect.processEvents()
to make sure the GUI is being updated.mainWindow.setAttribute(Qt::WA_QuitOnClose);
in main.cpp.I just want the application to completely exit when the main window is closed.
I'm using the qextserialport library, if that makes any difference.
I don't know what's wrong, but as your slot actually receives the signal, you can call exit()
from that slot function as a workaround.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With