Exiting Qt application does not kill spawned threads
I have a Qt program that is using the QtConcurrent API to spawn worker threads. The problem I am having is that the worker threads keep going even if I exit the Qt application.
I have an actionExit in my menu, which is what i am using to cl开发者_如何转开发ose the app, or the "X" in the window corner. Is there any way to make these kill off all threads related to this app?
Thanks
Are you sure that the UI application really closes? You might be missing:
qApp->setQuitOnLastWindowClosed(true);
Otherwise QT only hides your window. To debug put a breakpoint behind your
mainWindow->exec();
and see whether it is really reached.
If you confirm that exec() returns and QTConcurrent really hangs (it might be possible: http://lists.trolltech.com/qt-interest/2008-06/thread00414-0.html), then do:
exit(0);
精彩评论