我正在尝试使用QProcess
来启动Microsoft word,如下所示:
QString program = "WINWORD.EXE";
process->start(program);
但什么也没发生。
winword.exe
在路径上(因此,当我键入winword.exe时,单词将打开)。这是正确的方法吗?
最佳答案
下面的代码可能会帮助您:
QProcess *process = new QProcess(this);
QString program = "explorer.exe";
QString folder = "C:\\";
process->start(program, QStringList() << folder);
我认为您正在尝试执行不包含全局$ PATH Windows变量的程序,这就是为什么winword.exe无法执行的原因。
另外,您可能需要定义程序的绝对路径,例如:
QString wordPath = "C:\\Program Files\\Microsoft Office\\Office12\\WINWORD.EXE"
process->start(wordPath, QStringList() << "");
关于qt - 使用QProcess开始一个过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2622864/