Starting external process in QT without command prompt in Windows

陌路散爱 提交于 2019-12-12 12:44:46

问题


I'm try to start an external process in Qt with QProcess.startDetached(). I am able to successfully start the process, however when I do this I see an ugly Windows command prompt pop up. Is there any way to prevent this from happening?


回答1:


I use that method as well and do not have that problem. There are applications that create a command prompt when they are started. It may not be the Qt code that's at fault. You can validate that by setting up your code to start a different application and checking if it still creates a command prompt.

   QString program = "client.exe";
   QStringList arguments;

   ClientProcess = new QProcess( this );

   // exit calling application on called application start
   connect( ClientProcess, SIGNAL( started() ), this, SLOT( Exit() ) );
   // receive errors
   connect( ClientProcess, SIGNAL( error( QProcess::ProcessError ) ), this, SLOT( error( QProcess::ProcessError ) ) );

   ClientProcess->startDetached( program, arguments );


来源:https://stackoverflow.com/questions/6778350/starting-external-process-in-qt-without-command-prompt-in-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!