I am developing an application that creates and runs another Qprocess. My code is:
QProcess myProcess = new QProcess();
connect(myProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(sendProcessCompleted(int,QProcess::ExitStatus)));
connect(myProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(sendProcessError(QProcess::ProcessError)));
myProcess->start(program, arguments);
void SensorSimulator::sendProcessCompleted(int exitError, QProcess::ExitStatus exitStatus)
{
if(exitStatus == QProcess::CrashExit)
{
QString errorMessage("SensorSimulator is unexpectedly crashed.");
emit ProcessError(errorMessage);
}
else
{
QString p_stdout = myProcess->readAllStandardOutput();
QString p_stderr = myProcess->readAllStandardError();
}
}
void SensorSimulator::sendProcessError(QProcess::ProcessError error)
{
QString p_stdout = myProcess->readAllStandardOutput();
QString p_stderr = myProcess->readAllStandardError();
QString errorMessage;
errorMessage = "SensorSimulator is unexpectedly crashed. ProcessError: " + error;
//emit ProcessError(errorMessage);
}
I am getting this exception in the p_stdout:
Running, to stop press 'S' or close the window. Exception Found: Type: System.InvalidOperationException Message: Cannot see if a key has been pressed when either application does not have a console or when console input has been redirected from a file. Try Console.In.Peek.
Can anyone please help?
EDIT: the process I am running is a .Net application