Start a process using QProcess

前端 未结 6 1868
爱一瞬间的悲伤
爱一瞬间的悲伤 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:48

    If the method, where you're trying to launch external process, is finished right after your code, e.g.:

    void foo() {
        ...
        QString program = "WINWORD.EXE";
        process->start(program);
    }
    

    and variable

    process
    

    was declared as local variable, it will be destroyed at the end of method and no external process will be started - or correctly you won't see it because it will be destroyed right after start.

    It was the reason for similar issue in my case. Hope it helps.

提交回复
热议问题