Hello,
I uses QProcess to start a new process as with the code below. I know my spawned process works fine when I run it independent of the Qt GUI. For some reason when I try to start the process from my Qt GUI, it starts and runs for about a second then just exits. The error code I get from waitForStart is “2: The last waitFor…() function timed out. The state of QProcess is unchanged, and you can try calling waitFor…() again”. Any thoughts? Also, the funny thing is if I use start() instead of startDetached() the program doesnt even start. Maybe someone knows why this may be as well?
QObject *parent;
QString program = "\"C:\\Documents and Settings\\Ryan\\My Documents..."";
QString workingDir = "\"C:\\Documents and Settings\\Ryan\\My Documents..."";
QProcess *controllerProcess = new QProcess(parent = 0);
controllerProcess->setWorkingDirectory(workingDir);
controllerProcess->startDetached(program);
if(!controllerProcess->waitForStarted(10000))
{
qDebug() << "Controller process failed to start!";
qDebug() << "Process State: " << controllerProcess->state() << " " << "Error Code: " << controllerProcess->error() << " " << "Exit Status: " << controllerProcess->exitStatus();
return -1;
}
Thanks in advance!
↧