问题
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