How to test with code readAllStandardError.isEmpty() is not empty ?
-
i want to test QProcess's readAllStandardError() return error . if possible please give me code that return error bytes.
sError = qProcessSysCmd->readAllStandardError(); if(!sError.isEmpty()) { AppLog::AddLog(LOG_ERROR, __FUNCTION__, __LINE__, sCommand + " sError:" + sError); #ifdef QDEBUG_ENABLE pMainApp.ObjSettings.DebugStation(sCommand + " error : " + sError); #endif bIsError = true; }
-
@Qt-embedded-developer
in my example this shouldn't be possible.
So i guess your question is based on different usage?My example connects to the readyReadStandardError signal, which ensures that there is data available, further it checks if it can read a line before it finally reads the line.
Thats the way to go if you want the stderr output during the execution of the process.
Use readAllStandardError() on the other hand after the process has finished. -
@Qt-embedded-developer
For example:connect( myProc, &QProcess::readyReadStandardError, this, [myProc](){ myProc.setReadChannel(QProcess::StandardError); // for stdout use QProcess::StandardOutput while( myProc.canReadLine() ) myProc->readLine() // line of stderr } );
-
@raven-worx said in How to test with code readAllStandardError.isEmpty() is not empty ?:
myProc->readLine()
when myProc->readLine() return zero value means error occured. am i right or not.
-
@Qt-embedded-developer
in my example this shouldn't be possible.
So i guess your question is based on different usage?My example connects to the readyReadStandardError signal, which ensures that there is data available, further it checks if it can read a line before it finally reads the line.
Thats the way to go if you want the stderr output during the execution of the process.
Use readAllStandardError() on the other hand after the process has finished.