[Qt-interest] QProcess::start() fails with win32 paths

Marco Borm qt-lists at retrodesignfan.eu
Mon Apr 6 23:43:03 CEST 2009


Hi Stephen,

I haven't tried that but just after a look into the docs the reason is
clear:
void QProcess::start ( const QString & program, OpenMode mode = ReadWrite )
"/program/ is a single string of text containing both the program name
and its arguments."

So try to start a app called "C:/Program" with arguments "Files/MDP" and
"1.0.0/MDP_1.0.0/bin/protocol_manager_exe.exe"
So please use quotes if you have spaces in your program name and/or
arguments.


Marco


Stephen Collyer wrote:
> I have some code that does this:
>
>     QString command = QCoreApplication::applicationDirPath() + 
> "/protocol_manager_exe";
> #ifdef Q_OS_WIN
>     command += ".exe";
> #endif
>
> ..
>
>     QProcess* proc = new QProcess();
>     proc->setEnvironment(env);
>     proc->start(command);
>
> When command contains:
>
> C:/Program Files/MDP 1.0.0/MDP_1.0.0/bin/protocol_manager_exe.exe
>
> it fails to start the external process with an QProcess::error() of 0.
>
> When I put the same process in c: so that command contains:
>
> c:/protocol_manager_exe.exe
>
> then the process starts correctly. This behaviour seems to be 
> identical between Qt 4.4 and Qt 4.5
>
> Can anyone suggest what the problem is here ?
>
> -- 
> Stephen Collyer
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>   





More information about the Qt-interest-old mailing list