本文介绍了Qt-等待Qprocess完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在通过 QProcess
使用CMD,但是有问题。
I'm using CMD by QProcess
but I have a problem.
我的代码:
QProcess process;
process.start("cmd.exe");
process.write ("del f:\\b.txt\n\r");
process.waitForFinished();
process.close();
当我不传递 waitForFinished()$的参数时c $ c>等待30秒。我想在执行CMD命令后终止
QProcess
!不多也不少!
When I don't pass an argument for waitForFinished()
it waits for 30 secs. I want to terminate QProcess
after CMD command is executed! Not much and not less!
推荐答案
您需要通过发送 exit终止cmd.exe
命令,否则将等待命令
这是我的建议:
You need to terminate the cmd.exe by sending exit
command, otherwise it will wait for commandsHere is my suggestion:
QProcess process;
process.start("cmd.exe");
process.write ("del f:\\b.txt\n\r");
process.write ("exit\n\r");
process.waitForFinished();
process.close();
这篇关于Qt-等待Qprocess完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!