Start a process using QProcess

前端 未结 6 1861
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-09 06:09

I\'m trying to start Microsoft word using QProcess as following:

QString program = \"WINWORD.EXE\";
process->start(program);
<
6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-09 06:45

    You can just set the working directory:

    myProcess = new QProcess();
    myProcess->setWorkingDirectory("C:\\Z-Programming_Source\\Java-workspace\\Encrypt1\\bin\\");
    

    Or do it at start:

    myProcess->start("dir \"My Documents\"");
    

    At start() you can enter a command for the console... read the manual.

    I prefer the first option. More readable.

提交回复
热议问题