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;
与本文相关的文章
- Windows10系统自带的五笔输入法替换98字库
- 电脑声音一直显示小红叉,且右键还扬声器程序unknown
- *srv.exe蠕虫病毒打开exe程序弹浏览器窗体的解决方案
- 招生信息网服务器错误,中考报名网登录说密码错误怎么办
- 虚拟机VMware显示“内部错误”怎么办?
- Windows获取系统、进程CPU占用率、内存、磁盘、网卡
- 小米路由器花生壳动态DDNS连接错误
- win10上打包的qt程序放到win7上打不开的解决方法
- 怎么在WINDOWS中运行C语言程序,在Windows下运行C语言程序
- Windows环境下不用第三方程序给新硬盘提前预装Windows系统
- 重装系统后ip地址错误,网络无法接通怎么办
- python自动化程序操作浏览器在后台访问网站
- Edge浏览器扩展程序移植
- Windows操作系统的各进程的作用
- 阮工的单片机编程经验集:如何做稳定单片机程序与上位机程序防卡顿,js等经验;阮丁远于20250321
- python调用浏览器打开网页_python调用浏览器,实现刷网页浏览小程序!
- Git账号密码输入错误后怎么办
- EasyNVR无插件H5HLSm3u8直播解决方案中Windows系统服务启动错误问题的修复:EasyNVR_Service 服务因 函数不正确。 服务特定错误而停止。
- java程序在windows系统作为服务程序运行
- windows 10 双系统删除ubuntu系统分区,导致grub rescue错误
评论列表(0)
- 暂无评论