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 ?
To start a process, pass the name and command line arguments of the program you want to run as arguments to start(). Arguments are supplied as individual strings in a QStringList. Alternatively, you can set the program to run with setProgram() and setArguments(), and then call start() or open().
void QProcess::kill () const [slot] The nice way to end a process and to be sure that it is finished, is to do something like this: process->tryTerminate(); QTimer::singleShot( 5000, process, SLOT( kill() ) );
We can see, PID value from Qt : QProcess get PID is equal with PID from konsole command. You can get the complete source code from Qt : QProcess get PID in here.
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() << "");
For me, I need to add " characteres :
m_process->start("\"C:\\Program Files (x86)\\Notepad++\\notepad++.exe\"");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With