[Solved] How to compare data read from process->readAllStandardOutput() with a string
-
hai,
I am reading the data from process->readAllStandardOutput() to a QByteArray.in my application I want to compare data read from process with one string, depends upon the string only I will do further step.
I did as below but it's not working
@QByteArray b1=process->readAllStandardOutput() ;
char* text="Unable to read data";
if(strcmp(b1.data(),text)==0)
ui1->THI_Data->setText(text);@but it does not enter into if condition.
how can I compare the data
-
Hi,
You should rather use QString. It has all the function needed for what you want
-
Did you simply check/print the content of b1 ? You might have more data than you think.
-
if the condition fails it means they are not the same. Maybe a control char like \n that you did not see.
-
Can you post the exact content of b1 ?
And the code using QString for the comparison ? -
please given the result of
qDebug()<<b1.toHex();
and
qDebug()<<QByteArray(text).toHex();
-
Could you share the solution ?
Since you got it working, please update the thread title prepending [solved] so other forum users may know that it is working now :)