Firstly, i have seen this answer.
I'm currently using Qt 5.8 on Mac, and tried below codes:
QString test("/Users/test/Documents/ASCII Tables.pdf");
qDebug() << test.replace(" ", "\\ ");
expected result shoud be like:
"/Users/test/Documents/ASCII\ Tables.pdf"
what i got is two blackslashes are added:
"/Users/test/Documents/ASCII\\ Tables.pdf"
Anyone has suggestion?
Update: (regarding to @docsteer's answer) i intended to use the QString test
as part of QProcess:start()
, for example:
QProcess process;
process.start("ls " + test);
process.waitForFinished(-1);
qDebug() << process.readAllStandardOutput();
qDebug() << process.readAllStandardError();
and the result is not as expected, as both backslashes are inserted into the command:
""
"ls: /Users/test/Documents/ASCII\\: No such file or directory\nls: Tables.pdf: No such file or directory\n"