问题描述
我尝试使用QProcess.startDetached()在Qt中启动外部进程。我能够成功启动该过程,但是当我这样做时,我看到弹出一个难看的Windows命令提示符。有什么方法可以防止这种情况发生?
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?
推荐答案
我也使用该方法,但没有出现此问题。有些应用程序在启动时会创建命令提示符。可能不是Qt代码有问题。您可以通过设置代码来启动其他应用程序并检查它是否仍创建命令提示符来验证这一点。
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 );
这篇关于在Windows中在没有命令提示符的情况下在QT中启动外部进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!