-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathresultparser.cpp
More file actions
38 lines (27 loc) · 828 Bytes
/
Copy pathresultparser.cpp
File metadata and controls
38 lines (27 loc) · 828 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
26
27
28
29
30
31
32
33
34
35
36
#include "resultparser.h"
ResultParser::ResultParser(QObject *parent) : QObject(parent)
{
}
QString ResultParser::OrderResult(QString s)
{
QString path="C:\\Users\\shive\\OneDrive\\Desktop\\m.py";
QFile file(path);
if(file.open(QIODevice::WriteOnly | QIODevice::Text))
{
QTextStream stream(&file);
QString addFunc="def add(a,b):\n return a+b\n";
QString subFunc="def subtract(a,b):\n return a-b\n";
QString mulFunc="def multiply(a,b):\n return a*b\n";
stream<<addFunc<<endl;
stream<<subFunc<<endl;
stream<<mulFunc<<endl;
stream<<"\n"<<s<<endl;
}
file.close();
QProcess q;
q.start("python "+path);
q.waitForFinished();
QString output(q.readAllStandardOutput());
output.replace("\r\n","");
return output;
}