Try this 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()) );
}
QProcess *p = new QProcess( this );
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()) );
}
To copy to clipboard, switch view to plain text mode
And in slots ReadOut() and ReadErr():
QProcess *p
= dynamic_cast<QProcess
*>
( sender
() );
if (p)
ui->textBrowser->append( p->readAllStandardOutput() ); // p->readAllStandardError()
QProcess *p = dynamic_cast<QProcess *>( sender() );
if (p)
ui->textBrowser->append( p->readAllStandardOutput() ); // p->readAllStandardError()
To copy to clipboard, switch view to plain text mode
Bookmarks