PDA

View Full Version : QProcess issue with single quote ' on argument (win)



louissmr
15th July 2013, 19:50
Hi,

I having a weird issue using QProcess. I have two Qt (4.8.4) apps, the firts one starts detached the second one, passing a filePath as argument.

Invocation from app1:


QProcess::startDetached("app2Path/app2",QStringList() << filePath);

Getting the argument in app2


QString filePath= QCoreApplication::arguments().at(1);

if filePath contains a single quote ', the quote doesn't appears in filePath app2. Example:


QProcess::startDetached("app2Path/app2",QStringList() << "c:/temp/1'1.file");
...
QString filePath= QCoreApplication::arguments().at(1);

filePath is: "c:/temp/11.file"

Launching app2 from command line, only works fine if I use double quotes in the argument:

app2 c:\temp\1'1.file --> don't work
app2 "c:\temp\1'1.file" --> OK

What is going on? I haven't test this issue in MacOSX or Linux.

Santosh Reddy
15th July 2013, 20:02
Then start with double quoted arguments

QProcess::startDetached("app2Path/app2 \"c:/temp/1'1.file\"")

louissmr
15th July 2013, 20:49
Thank you, I totally missed this approach :)

BTW, this is not working (app2 doesn't start):

QProcess::startDetached("app2Path/app2 \"c:/temp/1'1.file\"")
I have fixed it, doing this:

QProcess::startDetached("app2Path/app2 \"c:/temp/1'1.file\"",QStringList())
:confused: