You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
Inspired by http://www.xargs.com/qml/process.html
|
|
|
|
|
|
|
|
## Setup
|
|
|
|
|
|
|
|
Add to project.pro:
|
|
|
|
|
|
|
|
```
|
|
|
|
HEADERS += \
|
|
|
|
../../qml-process/process.h
|
|
|
|
```
|
|
|
|
|
|
|
|
Add to main.cpp
|
|
|
|
|
|
|
|
```c++
|
|
|
|
#include <QtQml>
|
|
|
|
#include "../../qml-process/process.h"
|
|
|
|
|
|
|
|
// in main:
|
|
|
|
qmlRegisterType<Process>("Process", 1, 0, "Process");
|
|
|
|
```
|
|
|
|
|
|
|
|
also, add the `SimpleProcess.qml` and `SimpleProcess.js` files to your
|
|
|
|
project.
|
|
|
|
|
|
|
|
The simplest way to use it is to call the `callProcess` function:
|
|
|
|
|
|
|
|
```js
|
|
|
|
import "SimpleProcess.js" as SimpleProcess
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Component.onCompleted {
|
|
|
|
SimpleProcess.callProcess("echo", ["Hello", "World"], (_, stdout)=>console.log(stdout))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|