-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
25 lines (21 loc) · 751 Bytes
/
main.cpp
File metadata and controls
25 lines (21 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <QCoreApplication>
#include <QProcess>
#include <QtDebug>
int main(int argc, char *argv[])
{
QCoreApplication* a = new QCoreApplication(argc, argv);
QProcess* p = new QProcess();
QObject::connect(p, &QProcess::readyReadStandardError, [=](){
qDebug() << "StdErr: " << p->readAllStandardError();
});
QObject::connect(p, &QProcess::readyReadStandardOutput, [=](){
qDebug() << "StdErr: " << p->readAllStandardOutput();
});
QObject::connect(p, QOverload<int>::of(&QProcess::finished), a,
[=](int exitCode){
qDebug() << "Exited with code: " << exitCode;
a->exit(exitCode);
});
p->execute("sh", {"-c", "echo start && sleep 3 && echo test && exit 0"});
a->exec();
}