应用程序关闭后,Qt进程保留在内存中 [英] Qt process stays in memory after application closes

查看:2170
本文介绍了应用程序关闭后,Qt进程保留在内存中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的应用程序启动QDialog从它的主要像这样:

i have simple application that start QDialog from its main like this :

int main(int argc, char *argv[])
 {
     Q_INIT_RESOURCE(resources); 
     QApplication app(argc, argv);
     QCoreApplication::setApplicationName(APP_NAME);
     QCoreApplication::setApplicationVersion(APP_VERISON);
     QCoreApplication::setOrganizationDomain(APP_DOMAIN);
     app.setStyle("WindowsXP");    
     QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
     QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));

         AuthenticationDialogContainer *pAuthenticationDialogContainer = new AuthenticationDialogContainer();
     if(pAuthenticationDialogContainer->exec() != QDialog::Accepted ) {
         return 0;
     }



     return app.exec();
}



<和应用程序做什么是假设做。当我打开windows xp任务管理器,我看到的过程仍然在内存中,我需要手动杀死它。如何防止它发生?

when its pass the end of the application that is after app.exec() and the application doing what is suppose to do . when i open the windows xp task manager i see that the process is still in memory and i need manually kill it . how can i prevent it from happening ?

推荐答案

QDialog :: exec是一个阻塞调用:此代码显示并关闭对话框QApplication开始。

您可以使用QDialog :: show并处理QDialog :: accept方法中的返回代码。

QDialog::exec is a blocking call: this code show and close the dialog before the QApplication start.
You can use QDialog::show and handle the return code in QDialog::accept method.

这篇关于应用程序关闭后,Qt进程保留在内存中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆