forked from hazybluedot/qtbc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
38 lines (34 loc) · 1.02 KB
/
mainwindow.cpp
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
37
38
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QProcess>
#include <iostream>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
calc.start("bc", QStringList() << "-q");
calc.waitForStarted();
calc.write("scale=4\n");
bool status = connect(&calc, SIGNAL(readyReadStandardOutput()), this, SLOT(on_calc_readyRead()));
}
MainWindow::~MainWindow()
{
calc.close();
calc.waitForFinished();
delete ui;
}
void MainWindow::on_pushButton_calc_clicked()
{
std::cerr << "Got a button push!" << std::endl;
QString input = ui->lineEdit->text();
input.append("\n");
std::cerr << "Writing " << input.toStdString() << " to process stdin. I think." << std::endl;
calc.write(input.toLocal8Bit());
line = input.trimmed().append("=");
}
void MainWindow::on_calc_readyRead()
{
std::cerr << "Got a readyReadStandardOutput signal!" << std::endl;
ui->textBrowser->append(line.append(calc.readAllStandardOutput()).trimmed());
}