MainWindow
::MainWindow(QWidget *parent, Qt
::WFlags flags
){
process
= new QProcess(this);
// create on the heap, so it doesn't go out of scope connect (process, SIGNAL(readyReadStandardOutput()), this, SLOT(processOutput())); // connect process signals with your code
connect (process, SIGNAL(readyReadStandardError()), this, SLOT(processOutput())); // same here
process->start(program, args); // start the process
}
// this gets called whenever the process has something to say...
void MainWindow::processOutput()
{
qDebug() << process->readAllStandardOutput(); // read normal output
qDebug() << process->readAllStandardError(); // read error channel
}
MainWindow::MainWindow(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
process = new QProcess(this); // create on the heap, so it doesn't go out of scope
connect (process, SIGNAL(readyReadStandardOutput()), this, SLOT(processOutput())); // connect process signals with your code
connect (process, SIGNAL(readyReadStandardError()), this, SLOT(processOutput())); // same here
process->start(program, args); // start the process
}
// this gets called whenever the process has something to say...
void MainWindow::processOutput()
{
qDebug() << process->readAllStandardOutput(); // read normal output
qDebug() << process->readAllStandardError(); // read error channel
}
To copy to clipboard, switch view to plain text mode
Bookmarks