C++ (Qt) console = new QProcess; console->setReadChannel (QProcess::StandardError); QByteArray arr; /*if (!console->startDetached("/usr/bin/xterm",QStringList()<< "-e" << "./myprogram" << *args << filename))*/ if (!console->execute ("./myprogram",QStringList() << *args << filename)) { } arr = console->readAllStandardOutput(); std::cout << arr.data(); // editor объявлен как QTextEdit *editor; editor ->insertPlainText( arr.data() );
C++ (Qt) console = new QProcess; console->setReadChannel (QProcess::StandardError); QByteArray arr; /*if (!console->startDetached("/usr/bin/xterm",QStringList()<< "-e" << "./myprogram" << *args << filename))*/ if (!console->execute ("./myprogram",QStringList() << *args << filename)) { } arr = console->readAllStandardOutput(); std::cout << arr.data(); editor ->insertPlainText( arr.data() );
C++ (Qt) if (!console->execute ("./myprogram",QStringList() << *args << filename))
C++ (Qt)arr = console->readAllStandardOutput();
C++ (Qt)/* -------------------------------------------------------------------------- */ void MainWindow::readErr() { arr = new QByteArray; *arr = console->readAllStandardError(); }/* -------------------------------------------------------------------------- */ void MainWindow::run() { console = new QProcess; console->setReadChannel (QProcess::StandardError); console->start("./myprogram",QStringList() << *args << filename); connect(console, SIGNAL(readyReadStandardError()), this, SLOT(readErr())); std::cout << arr->data(); editor ->insertPlainText( arr->data() ); .../* -------------------------------------------------------------------------- */
void MainWindow::finished() { arr = new QByteArray; *arr = console->readAllStandardError(); std::cout << arr->data(); editor ->insertPlainText( arr->data() ); } void MainWindow::run() { console = new QProcess; connect(console, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(finished())); console->setReadChannel (QProcess::StandardError); console->start("./basin",QStringList() << *args << filename); }