#include “buttonwidget.h”
#include “ui_buttonwidget.h”
ButtonWidget::ButtonWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::ButtonWidget)
{
ui->setupUi(this);
p = new QProcess(this);
connect(p, SIGNAL(readyRead()), this, SLOT(read()));
connect(p, SIGNAL(finished(int)), this, SLOT(finished()));
}
ButtonWidget::~ButtonWidget()
{
delete ui;
}
void ButtonWidget::on_pushButton_clicked()
{
QString str = ui->lineEdit->text();
qDebug()<<str;
p->start(str);
}
void ButtonWidget::read()
{
str += QString::fromLocal8Bit(p->readAll());
}
void ButtonWidget::finished()
{
ui->textEdit->setText(str);
str.clear();
}
void ButtonWidget::on_pushButton_2_clicked()
{
ui->textEdit->clear();
}