SecondWindow::SecondWindow(QWidget* parent)
: QDialog(parent)
, ui(new Ui::SecondWindow)
{
ui->setupUi(this);
m_process = new QProcess(this);
connect(m_process, &QProcess::readyReadStandardOutput, this, &SecondWindow::setStdout);
connect(ui->lineEdit_4, SIGNAL(returnPressed()), this, SLOT(command()));
}
SecondWindow::~SecondWindow() { delete ui; }
void SecondWindow::setStdout()
{
if (QSysInfo::productType() == "windows") {
QTextCodec* codec = QTextCodec::codecForName("IBM 866");
ui->textEdit->append(codec->toUnicode(m_process->readAllStandardOutput()));
}
else
ui->textEdit->append(m_process->readAllStandardOutput());
ui->lineEdit_4->clear();
}
void SecondWindow::command()
{
QString strCommand;
if (QSysInfo::productType() == "windows")
strCommand = "cmd ";
QStringList arguments;
arguments << "/C" << ui->lineEdit_4->text();
m_process->start(strCommand, arguments);
}