start函数的路径不能有空格,如果路径是有空格的该怎么处理?
------解决方案--------------------
用/s转义。Qt帮助文档中关于
QProcess的start函数有例子的
------解决方案--------------------
QProcess process;
process.start("del /s *.txt");
// same as process.start("del", QStringList() << "/s" << "*.txt");
------解决方案--------------------
空格不用管在要执行的路径前和后加上双引号就可以。
比如process.start("D:\Program Files\XiaZaiBa.exe");
写成process.start("\"D:\Program Files\XiaZaiBa.exe\"");就可以了。
------解决方案--------------------
window和Linux处理是不同的转义 qt助手上是如下写的
The program string can also contain quotes, to ensure that arguments containing spaces are correctly supplied to the new process. For example:
QProcess process;
process.start("dir \"My Documents\"");
If the QProcess object is already running a process, a warning may be printed at the console, and the existing process will continue running.
Note that, on Windows, quotes need to be both escaped and quoted. For example, the above code would be specified in the following way to ensure that "My Documents" is used as the argument to the dir executable:
QProcess process;
process.start("dir \"\"\"My Documents\"\"\"");
------解决方案--------------------
process.start("C:\\124 45\\56 78\\bb.exe");
或者
process.start("C:\\124 \s 45 \s \\56 \s 78\\bb.exe");