<file_sep>#ifndef PROCESS_H
#define PROCESS_H
#include <QProcess>
#include <QVariant>

class Process : public QProcess {
    Q_OBJECT
    Q_DISABLE_COPY(Process)

public:

    Process(QObject *parent = nullptr);
    ~Process();
    Q_INVOKABLE void start(const QString &program, const QVariantList &arguments);
    Q_INVOKABLE QByteArray readAll();
    Q_INVOKABLE QByteArray readAllStandardOutput();
    Q_INVOKABLE QByteArray readAllStandardError();
};

#endif // PROCESS_H
<file_sep>#include "process_plugin.h"
#include "process.h"

#include <qqml.h>

void ProcessPlugin::registerTypes(const char *uri)
{
    // @uri com.example.Process
    qmlRegisterType<Process>(uri, 1, 0, "Process");
}

<file_sep>#include "process.h"

Process::Process(QObject *parent) : QProcess(parent)
{
}

Process::~Process()
{
}

void Process::start(const QString &program, const QVariantList &arguments) {
    QStringList args;

    // convert QVariantList from QML to QStringList for QProcess
    for (int i = 0; i < arguments.length(); i++)
        args << arguments[i].toString();

    QProcess::start(program, args);
}

QByteArray Process::readAll() {
    return QProcess::readAll();
}

QByteArray Process::readAllStandardOutput() {
    return QProcess::readAllStandardOutput();
}

QByteArray Process::readAllStandardError() {
    return QProcess::readAllStandardError();
}
