关于QProcess的start函数

shn521 2013-02-27 06:20:55
start函数的路径不能有空格,如果路径是有空格的该怎么处理?
...全文
979 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jody_go 2013-02-28
  • 打赏
  • 举报
回复
process.start("C:\\124 45\\56 78\\bb.exe"); 或者 process.start("C:\\124 \s 45 \s \\56 \s 78\\bb.exe");
乔巴好萌 2013-02-27
  • 打赏
  • 举报
回复
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\"\"\"");
zhjun5337 2013-02-27
  • 打赏
  • 举报
回复
空格不用管在要执行的路径前和后加上双引号就可以。 比如process.start("D:\Program Files\XiaZaiBa.exe"); 写成process.start("\"D:\Program Files\XiaZaiBa.exe\"");就可以了。
shn521 2013-02-27
  • 打赏
  • 举报
回复
引用 1 楼 jody_go 的回复:
用/s转义。Qt帮助文档中关于 QProcess的start函数有例子的
引用 2 楼 heksn 的回复:
QProcess process; process.start("del /s *.txt"); // same as process.start("del", QStringList() << "/s" << "*.txt");
请问例如路径为:C:\124 45\56 78\bb.exe。该怎么写?
  • 打赏
  • 举报
回复
QProcess process; process.start("del /s *.txt"); // same as process.start("del", QStringList() << "/s" << "*.txt");
jody_go 2013-02-27
  • 打赏
  • 举报
回复
用/s转义。Qt帮助文档中关于 QProcess的start函数有例子的

16,815

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧