Qt5.5.1
QtCreator 3.5.1
Windows 7
Hello,
I'm trying to build a QString for a QProcess command.
I'm getting stray '\' (back slashes) in my output where I try to insert a ".
It appears that I need the " in 'cmd' as there are spaces in the path and file names.
I can't work out how to remove the '\' from the 'cmd' QString (I've tried various variations)
or not to get them there in the first place.
I think its something to do with 'escaping' but not sure what or how.
Help would be appriciated.
Regards
cmd.append(fileinfo.fileName());
cmd.append(" *.* ");
cmd.append("-o");
cmd.append('"'); //QString output = "Hello \"world\"!"; //string literal - works
cmd.append(destination);
cmd.append("/Files to copy");
cmd.append('"');
cmd.append(" -r");
qDebug() << cmd;
QString cmd = ("7z x -y ");
cmd.append(fileinfo.fileName());
cmd.append(" *.* ");
cmd.append("-o");
cmd.append('"'); //QString output = "Hello \"world\"!"; //string literal - works
cmd.append(destination);
cmd.append("/Files to copy");
cmd.append('"');
cmd.append(" -r");
qDebug() << cmd;
To copy to clipboard, switch view to plain text mode
qDebug output:-
"7z x -y myFile.zip *.* -o\"H:/my dir/systems/output files\" -r"
^ ^
Terminal commmand, works ok.
7z x -y myFile.zip *.* -o"H:/my dir/systems/output files" -r
qDebug output:-
"7z x -y myFile.zip *.* -o\"H:/my dir/systems/output files\" -r"
^ ^
Terminal commmand, works ok.
7z x -y myFile.zip *.* -o"H:/my dir/systems/output files" -r
To copy to clipboard, switch view to plain text mode
Bookmarks