PDA

View Full Version : SOLVED Linux, Capture output of program in console app



JeanC
12th February 2011, 11:03
Hi,
I'm starting of with QT and linux again after some years.
I want to write a little console app that starts another program and captures it's output.
After asking my question (the famous afterPostForumQuestionEvent) I figured it out:

int main(int argc, char *argv[])
{
ByteArray a;
QProcess p;
p.setProcessChannelMode(QProcess::MergedChannels);
p.start("astrolog b n z1 R -c 14");
p.waitForFinished(-1);
a = p.readAllStandardOutput();
qDebug() << a;
return 0;
}



Thanks. Jean.