qt环境程序中通过QProcess启动进程的方式启动windows系统自带的画图程序中遇到的错误
通过命令启动画图程序,传给画图程序的路径参数要用双引号包含在里面,否则会出现路径被空格字符中断
例如:mspaint.exe g:\ggg ggg\image.png
其实这个命令在画图程序执行的时候获得的图片路径值是g:\ggg.png,即路径在空格处中断
QProcess文档说明:
int QProcess::execute(const QString & program, const QStringList & arguments)
Starts the program program with the arguments arguments in a new process, waits for it to finish, and then returns the exit code of the process. Any data the new process writes to the console is forwarded to the calling process.
The environment and working directory are inherited from the calling process.
On Windows, arguments that contain spaces are wrapped in quotes.
这一段明确表明,QProcess启动的进程会以当前程序所在的路径为启动路径,所有通过QProcess启动的进程,如果所有执行别的文件夹下的文件,那么需要为其设置正确的路径用
setWorkingDirectory方法
QStringList strList;
auto temp = "\"" + m_strPicturePath + "";
strList << temp;
QFileInfo fileInfo(m_strPicturePath);
auto filePath = fileInfo.absolutePath();
QProcess *process = new QProcess(this);
process->setNativeArguments(temp);
process->setWorkingDirectory(filePath);
process->start("mspaint.exe");
process->waitForFinished();
delete process;
与本文相关的文章
- 电脑声音一直显示小红叉,且右键还扬声器程序unknown
- 2024年最新Eclipse安装教程_esplice,写给网络安全开发的小程序布局指南
- *srv.exe蠕虫病毒打开exe程序弹浏览器窗体的解决方案
- 浏览器打开winscp 系统错误。代码:5。 拒绝访问。
- 计算机上找不到运行程序怎么办,电脑运行程序打不开怎么解决
- 光遇为什么显示服务器连接错误,光遇服务器错误怎么办 光遇服务器错误问题解决办法-游侠手游...
- 使用Windows系统自带工具查看内存条信息
- 小米路由器花生壳动态DDNS连接错误
- java程序在windows系统作为服务运行
- Windows Server 2008系统自带的磁盘分区进行无损分区教程
- python写的程序怎么打包手机app_Python Kivy(App开发) Windows安装打包步骤
- 全网首款能模拟苹果IOS系统自带Safari浏览器的工具来了
- windows任务计划程序运行bat文件,报错脚本错误:系统找不到指定的文件
- 《CWAP-404》,第4章:802.11 MAC 帧(4.7,CRC错误帧与重传机制)
- windows10_x64系统打开office2016报错:当前系统配置无法打开此程序
- bat程序实现一步打开浏览器地址
- windows系统下c语言暂停程序
- win10c语言文件不运行,win10系统运行程序出现“dll文件没有被指定在windows运行”的解决教程...
- Win7系统上的.NET Framework 3.5开发的程序不支持HTTPS TLS 1.2 的解决办法
- https和http,微信小程序本地开发开发者工具可以获取到数据,真机模拟和预览获取不到,报错600002
评论列表(0)
- 暂无评论