单击按钮,我创建新的QProcess,它运行外部.exe,生成DXF文件(非常流行的CAD格式) . 当它发出finish()时,我'd like to end the process. I' ve尝试了两个选项:
1)myProcess-> delateLater() - >我的应用程序运行正常,输出是按预期的,但当我退出我的应用程序并尝试在AutoCAD中打开输出文件时,我收到消息"There was a problem sending a command to a program"(窗口的 Headers 指向一个位置输出文件) . 之后,文件被打开 .
2)myProcess-> kill() - >再次生成输出文件,但是当我尝试打开它时,会显示消息,它当前可以被其他程序使用,或者它只是读取文件 - 你做想以只读文件打开?我选择是的,一切都好 . 当我查看文件的特性时,它也可以写入 - 因此必须由其他程序使用 .
我的目标是打开没有这条消息的输出文件 . 我应该以某种方式修改我的QProcess吗?与之相关的代码如下:

MainWindow的私人:

QProcess *myProcess;

单击按钮,MainWindow:

QByteArray byteArray = fileLocation.toUtf8();
const char* cString = byteArray.constData();
//use potrace.exe to get the vectorized graphics
QString program = "potrace.exe";
QStringList arguments;
arguments << "-b" << "dxf" << "bAndWImg.ppm" << "-o" << cString;

myProcess = new QProcess();
myProcess->start(program, arguments);
//emit myProcess->finished();
connect(myProcess, SIGNAL(finished(int)), this, SLOT(processFinished()));

MainWindow插槽:

void MainWindow::processFinished()
{
myProcess->deleteLater();
}