it is the problem I have in my Qt
console application:
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
MyApp app;
app.start();
return a.exec();
} // <== MyApp destructor must be called to free up resourcs but not reach here
Qt version: 5.4.1
Platform: Windows 10
Already I have faced with this problem in Window 7
and not fixing this.
Problem is exec
call terminates process using exit
system call in Windows after exiting main event loop and doesn't return.
another soultions such as using aboutToQuit
signal of QCoreApplication
class not working.
Straight from Qt documentation :
We recommend that you connect clean-up code to the aboutToQuit() signal, instead of putting it in your application's main() function because on some platforms the exec() call may not return. For example, on Windows when the user logs off, the system terminates the process after Qt closes all top-level windows. Hence, there is no guarantee that the application will have time to exit its event loop and execute code at the end of the main() function after the exec() call .
You say you tried aboutToQuit()
with no luck but you should definitely focus on making that work. Would you please update the pasted code to include the aboutToQuit attempt so that we can help you?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.