-
Notifications
You must be signed in to change notification settings - Fork 2
/
console.cpp
61 lines (49 loc) · 1.57 KB
/
console.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include "console.h"
#include "ui_console.h"
Console::Console(QWidget *parent) :
QDialog(parent),
ui(new Ui::Console)
{
ui->setupUi(this);
}
Console::~Console()
{
delete ui;
}
bool Console::start() {
this->show();
this->repaint();
QString program = fusInvBinPath;
QStringList arguments;
arguments <<"--debug";
myProcess = new QProcess();
connect ( myProcess, SIGNAL(readyReadStandardError ()), this,
SLOT(updateConsole()));
ui->plainTextConsole->clear();
myProcess->start(program, arguments);
ui->plainTextConsole->appendPlainText(QString("Exit code: %1").arg(myProcess->exitCode()));
/* do {
std::cout<<"aa"<<std::endl;
QByteArray stdOutText = myProcess->readAllStandardOutput();
QByteArray stdErrText = myProcess->readAllStandardError();
std::cout<<stdOutText.data()<<std::endl;
std::cout<<stdErrText.data()<<std::endl;
std::cout<<"bb"<<myProcess->state()<<std::endl;
this->repaint();
QThread::wait(250);
myProcess->waitForFinished(1000);
} while(myProcess->state() != QProcess::NotRunning || myProcess->waitForReadyRead(500));*/
return true;
}
void Console::updateConsole () {
QByteArray stdOutText = myProcess->readAllStandardOutput();
QByteArray stdErrText = myProcess->readAllStandardError();
ui->plainTextConsole->insertPlainText(stdErrText.data());
ui->plainTextConsole->insertPlainText(stdOutText.data());
}
void Console::on_pushButtonOK_clicked()
{
myProcess->kill();
this->hide();
}