Real time display of QProcess output in a textBrowser
Hello,
I am a newbie in qt development and i want to transfer the output of QProcess to a textBrowser in real time. I started by executing a simple echo command,but the output of the program is not getting displayed.
What am i doing wrong????
Code:
p.waitForStarted();
QString line
= p.
readAllStandardOutput();
ui->textBrowser->append("not running");
ui->textBrowser->append(line);
p.waitForFinished();
Re: Real time display of QProcess output in a textBrowser
Try this code:
Code:
if (p)
{
p
->setEnvironment
( QProcess::systemEnvironment() );
p
->setProcessChannelMode
( QProcess::MergedChannels );
p
->start
( "cmd.exe",
QStringList() <<
"echo" <<
"hye" );
p->waitForStarted();
connect( p, SIGNAL(readyReadStandardOutput()), this, SLOT(ReadOut()) );
connect( p, SIGNAL(readyReadStandardError()), this, SLOT(ReadErr()) );
}
And in slots ReadOut() and ReadErr():
Code:
QProcess *p
= dynamic_cast<QProcess
*>
( sender
() );
if (p)
ui->textBrowser->append( p->readAllStandardOutput() ); // p->readAllStandardError()
Re: Real time display of QProcess output in a textBrowser
Thanks for the solution...was looking for this.