Start a process using QProcess

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

    may be code below will help you:

    QProcess *process = new QProcess(this);
    QString program = "explorer.exe";
    QString folder = "C:\\";
    process->start(program, QStringList() << folder);
    

    I think you are trying to execute program that doesn't consists in global $PATH windows variable, that's why winword.exe doesn't executes.

    Also you may need to define absolute path to program, e.g.:

    QString wordPath = "C:\\Program Files\\Microsoft Office\\Office12\\WINWORD.EXE"
    process->start(wordPath, QStringList() << "");
    

提交回复
热议问题