'QProcess can not find the file specified
I want to start a QProcess to execute an .exe file in the working directory with some arguments. The error string says that the specified file is not found indeed the executable is already in the working directory.
The output of the process under Win10 is:
workingDirectory: "\"C:\\devApp\\Build\\tmp\""
program: "dcmodify.exe"
arguments: (" -q", " -ie", " -gin", " -nb", " -ma", " (0010,0010)=na", " *.dcm")
error: "Process failed to start: system can not find the file specified."
If I execute same commands on the cmd I have no problems, such:
cd /d "C:\\devApp\\Build\\Tmp\" && dcmodify.exe -q -ie -gin -nb -ma (0010,0010)=na *.dcm
This is my code
QString workingDirectory =
QDir::toNativeSeparators(QDir::cleanPath(Utilities::getAppPath() +
QDir::separator() +
toQString("Build") +
QDir::separator() +
toQString("tmp") +
QDir::separator()));
QString executable = toQString("dcmodify.exe");
QStringList parameters;
parameters <<
toQString(" -q") <<
toQString(" -ie") <<
toQString(" -gin") <<
toQString(" -nb") <<
toQString(" -ma") <<
toQString(" (0010,0010)=na") <<
toQString(" *.dcm");
QProcess *proc = new QProcess(this);
proc->setWorkingDirectory(workingDirectory);
proc->setProgram(executable);
proc->setArguments(parameters);
proc->start();
bool retval = false;
while (retval = proc->waitForFinished());
if (!retval)
{
qDebug() << "workingDirectory:" << proc->workingDirectory();
qDebug() << "program:" << proc->program();
qDebug() << "arguments:" << proc->arguments();
qDebug() << "error:" << proc->errorString();
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
