关于void QProcess::start参数问题的解决
函数原型: void QProcess::start(const QString &program, const QStringList &arguments, OpenMode mode = ReadWrite)
问题: const QStringList &arguments 只能传入命令本身的参数,不能传入引用参数。
解决: 在windows下面需要使用setNativeArguments() 添加引用参数
Qt官方文档描述: void QProcess::start(const QString &program, const QStringList &arguments, OpenMode mode = ReadWrite)
Starts the given program in a new process, passing the command line arguments in arguments.
The QProcess object will immediately enter the Starting state. If the process starts successfully, QProcess will emit started(); otherwise, errorOccurred() will be emitted.
Note: Processes are started asynchronously, which means the started() and errorOccurred() signals may be delayed. Call waitForStarted() to make sure the process has started (or has failed to start) and those signals have been emitted.
Note: No further splitting of the arguments is performed.
Windows: The arguments are quoted and joined into a command line that is compatible with the CommandLineToArgvW() Windows function. For programs that have different command line quoting requirements, you need to use setNativeArguments(). One notable program that does not follow the CommandLineToArgvW() rules is cmd.exe and, by consequence, all batch scripts.
The OpenMode is set to mode.
If the QProcess object is already running a process, a warning may be printed at the console, and the existing process will continue running unaffected.
使用代码实例:
void Unpack()
{
QProcess pExe(0);
QString str7z;
//命令exe
str7z.append("E:\maozg tools\OuterNetPacketMaker\Bin\7z.exe");
//命令参数
QStringList strCMD;
strCMD.append("x");
strCMD.append("D:\111.zip");
//引用参数
QString strArg;
strArg.append("-y");
strArg.append("-o");
strArg.append("D:\");
strArg.append("*.txt");
strArg.append("-r");
pExe.setNativeArguments(strArg);
pExe.start(str7z, strCMD);
pExe.waitForStarted();
pExe.waitForFinished();
QString strTemp = QString::fromLocal8Bit(pExe.readAllStandardOutput());
QMessageBox testMassage1;
testMassage1.setText(strTemp);
testMassage1.exec();
}
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- Linux gdb+valgrind调试
- matplotlib基础绘图命令之hist
- Python|一文详解数据预处理
- 安排上了!PC人脸识别登录,出乎意料的简单
- valgrind使用介绍
- 实用!一键生成数据库文档,堪称数据库界的Swagger
- 算法集锦(2)|scikit-learn| 如何利用文本挖掘推荐Ted演讲
- 算法集锦(3)|采用医疗数据预测糖尿病的算法
- 谁说Cat不能做链路跟踪的,给我站出来
- Libra:一种Python工具,可以用几行代码自动实现机器学习过程
- 国内首个“新基建”安全大赛启动了!
- Kubernetes 中 Informer 的使用
- 嵌入式开发中常见3个的C语言技巧
- 恕我直言,我也是才知道ElasticSearch条件更新是这么玩的
- 有了MinIO,你还会用FastDFS么?