Qt 调用第三方应用程序
来源:互联网 发布:vb语言n的数值 编辑:程序博客网 时间:2024/05/19 22:26
Qt 调用第三方程序:
需要包含头文件<QProcess>
Windows记事本的路径在系统环境变量中,不用加参数,所以调用是比较容易的:
{
QProcess *po = new QProcess(this);//如果不在类中,则参数为空
po->start("notepad.exe");
}
2、调用cmd并获取输出信息:
执行一个ping 命令:
{
QProcess p(0);
p.start("cmd",QStringList()<<"/c"<<"ping www.csdn.net");
p.waitForStarted();
p.waitForFinished();
QString strTemp=QString::fromLocal8Bit(p.readAllStandardOutput());
QMessageBox testMessage;
testMessage.setText(strTemp);
testMessage.exec();
}
3、执行带参数的位置不在环境变量路径中的程序:
假设程序路径为"d:\test\a.exe":
执行命令格式为:a.exe -i in.txt -j 1600 -file out.txt;
则代码为:
{
QProcess *po = new QProcess(this);
QString program="d:\test\a.exe";
QStringList argu;
argu.append("-i");
argu.append("in.txt");
argu.append("-j");
argu.append("1600");
argu.append("-file");
argu.append("out.txt");
po->start(program,argu);
}
需要包含头文件<QProcess>
下面的三种方法中,前两种是阻塞方式,第三种是非阻塞方式执行。
Windows记事本的路径在系统环境变量中,不用加参数,所以调用是比较容易的:
{
QProcess *po = new QProcess(this);//如果不在类中,则参数为空
po->start("notepad.exe");
}
2、调用cmd并获取输出信息:
执行一个ping 命令:
{
QProcess p(0);
p.start("cmd",QStringList()<<"/c"<<"ping www.csdn.net");
p.waitForStarted();
p.waitForFinished();
QString strTemp=QString::fromLocal8Bit(p.readAllStandardOutput());
QMessageBox testMessage;
testMessage.setText(strTemp);
testMessage.exec();
}
3、执行带参数的位置不在环境变量路径中的程序:
假设程序路径为"d:\test\a.exe":
执行命令格式为:a.exe -i in.txt -j 1600 -file out.txt;
则代码为:
{
QProcess *po = new QProcess(this);
QString program="d:\test\a.exe";
QStringList argu;
argu.append("-i");
argu.append("in.txt");
argu.append("-j");
argu.append("1600");
argu.append("-file");
argu.append("out.txt");
po->start(program,argu);
}
阅读全文
0 0
- Qt 调用第三方应用程序
- 用qt调用第三方库
- Qt调用VS第三方库
- qt调用第三方SDK链接
- 用qt调用第三方库
- 用qt调用第三方库
- AIDL调用第三方应用程序服务中的方法
- 打开第三方应用程序
- Linux下Qt for Android 调用第三方库ZMQ
- qt 第三方库
- 调用第三方APP
- mac系统下发布qt第三方的应用程序(opencv)
- QT 添加第三方库
- QT 加载第三方库
- qt添加第三方库
- Qt使用第三方库
- Qt使用第三方库
- Qt-导入第三方库
- Java中为什么要序列化和序列化的几种方式
- Linux-启动和服务(service)
- Mysql账户创建及删除
- SQL数据库触发器
- MySQL 学习教程(五)【整理】-索引/ 关系/ 范式
- Qt 调用第三方应用程序
- [整理] 解决 Coursera 视频无法播放
- Error running app: Instant Run requires 'Tools | Android | Enable ADB integration' to be enabled
- magento 实现折扣为负值
- 虚幻引擎四 调用HTC Vive 手柄震动问题 ||UE4 调用手柄震动问题
- dede:sql
- python时间概念总结
- Populating Next Right Pointers in Each Node
- Precomputed Real-Time Texture Synthesis with Markovian Generative Adversarial Networks论文笔记