当前位置:网站首页>Explanation on the use of qpprocess
Explanation on the use of qpprocess
2022-07-19 16:22:00 【Biao】
QProcess There are two usage patterns :
- One is to call start() or execute(): At this time, the standard input of the called function 、 standard output 、 Standard error Have been redirected to QProcess In the corresponding pipe created . under these circumstances , Even if your console program has its own Console, Then it can neither receive any input , Nothing will be output . The parent process of the change process is still our own current process , therefore , It can be controlled .( So it's also called Controllable mode )
that , In this mode , If you expect to see a console window that should belong to it , Just follow me dev c++ Wait for the result of software compilation and operation , How does that need to be done :
Add a line of code :
process1.setCreateProcessArgumentsModifier(
[](QProcess::CreateProcessArguments *args) {
args->flags |= CREATE_NEW_CONSOLE;
args->startupInfo->dwFlags &=~ STARTF_USESTDHANDLES;
});principle : because QProcess The underlying call is windows The underlying Library of the platform Win32 API function CreateProcess() To create sub processes , And default to CreateProcess() In the arguments of the function , It indicates that the console window should not appear , So we want to show the console window , You need to modify the default to CreateProcess() The parameters of the function , It is realized through the above function .
And the subprocess will share This window of the parent process sets properties , Such as process A The setting starts the process by displaying the console window B, Input to B Among the parameters of is the process C The path of , Only one console window will appear , That's the process C The content of will be displayed in the process B In the console window .
Sample code :
QStringList arguments;
arguments;//
QProcess process1(this);
process1.setCreateProcessArgumentsModifier(
[](QProcess::CreateProcessArguments *args) {
args->flags |= CREATE_NEW_CONSOLE;
args->startupInfo->dwFlags &=~ STARTF_USESTDHANDLES;
});
process1.start("C:\\Users\\86132\\Documents\\panda_project\\test1.exe"/*,arguments*/);
process1.waitForStarted();
process1.waitForFinished();reference :
QProcess Calling an external program does not display the interface - sagerking - Blog Garden
Windows order QProcess eject CMD Interface _Sudouble The blog of -CSDN Blog
- Another usage is ,startDetached(): This is a QProcess After starting your console program , There is no additional operation , You can't control it in the current program ( It is an independent process , The parent process is not the current process , Therefore, it cannot be controlled ). however , stay Windows Next , There will be one you expect Console appear ; In other systems , There will be no terminal display .( Uncontrollable mode )
notes :
- Usually in English documents ,fine-tune It means fine-tuning , Such as parameter tuning
- passing it to Indicates that the xx Pass to xx, It's about delivering , Input meaning
- custom color scheme, Represents a custom color scheme ,custom It generally means custom , For example, software custom installation options
reference :
边栏推荐
- Vscode下Latex 图片引用时 编译报错Recipe terminated with error. Retry building the project.
- Ffifdyop bypasses MD5 for SQL injection
- 干货!综合的公平冷启动推荐系统
- Dynamic adding method and property modification of object extensions in typescript
- Wait quietly
- 解决MATLAB安装后出现 “License Manager Error -8”(亲测有效)
- 亿学学堂赠送的账户是哪家证券公司呢?开户安全吗
- How to implement Mysql to insert if it does not exist and update if it exists
- Ch549/ch548 learning notes 3 - UART
- 对象内存布局和synchronized锁升级
猜你喜欢

MySQL - unique key constraint for table fields

MySQL - 表字段的唯一键约束

Ch549/ch548 learning notes 7 - USB device initialization

Liquibase学习1 - 安装、简单使用

CSGO突然返回桌面,并且其他应用无反应,如何不重启关闭

Mathematical modeling -- the road from nature to Rationality -- Introduction to mathematical modeling (learning note 1)

MySQL - autoincrement constraint of table fields

解决MATLAB安装后出现 “License Manager Error -8”(亲测有效)

MySQL - default value constraint for table fields

HCIA -- OSPF experimental report
随机推荐
同花顺软件炒股线上开户收费吗?开户安全吗?
MySQL - table index overview
Ffifdyop bypasses MD5 for SQL injection
论文阅读 TEMPORAL GRAPH NETWORKS FOR DEEP LEARNING ON DYNAMIC GRAPHS
NFT市场格局仍未变化,Okaleido能否掀起新一轮波澜?
数学建模--从自然走向理性之路--数学建模概论(学习笔记1)
uniapp授权登陆获取用户信息和code
Through JMeter pressure measurement surging
Does flush software charge for online account opening for stock speculation? Is it safe to open an account?
Csgo suddenly returns to the desktop, and other applications are unresponsive. How can we not restart and close it
Solve the problem of "license manager error -8" after matlab installation (the personal test is valid)
各版本VOS服务的停止、启动和重启命令详解
Reading notes: self cultivation of programmers - Chapter 2
CSGO突然返回桌面,并且其他应用无反应,如何不重启关闭
Ch549/ch548 learning notes 9 - USB device endpoint processing
【单片机仿真项目】广告灯(proteus原理图+keil代码)
【单片机仿真项目】报警灯(proteus原理图+keil代码)
Latex基本语法总结
HCIA -- OSPF experimental report
关于双网卡配置后只能一个IP访问的问题