tags:

views:

58

answers:

2

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

QString program = "WINWORD.EXE";
process->start(program);

but nothing happens... winword.exe is on path (so when i type winword.exe word is openning up) is it the right way to do so ?

A: 

From Qt documentation:

Note: Processes are started asynchronously, which means the started() and error() signals may be delayed. Call waitForStarted() to make sure the process has started (or has failed to start) and those signals have been emitted.

Connect the signals mentioned in doc to some GUI control or debug output and see what happens. If there is an error, you should check the error type using QProcess::error().

chalup
+2  A: 

Hello, 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() << "");

Good luck!

mosg