From a9a895a0221f1f3eca4bbd7b4e4833a738bfa3ef Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Mon, 25 Apr 2022 22:18:06 +0200 Subject: [PATCH] Initial commit --- process.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 process.h diff --git a/process.h b/process.h new file mode 100644 index 0000000..e8ee93d --- /dev/null +++ b/process.h @@ -0,0 +1,27 @@ +#include +#include + +class Process : public QProcess { + Q_OBJECT + +public: + Process(QObject *parent = 0) : QProcess(parent) { } + + Q_INVOKABLE void 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); + } + + Q_INVOKABLE QByteArray readAll() { + return QProcess::readAll(); + } + Q_INVOKABLE QByteArray readAllStandardError() { + return QProcess::readAllStandardError(); + } +};