[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
-
even for QString also it's not enter to if condition I am already tested
-
Did you simply check/print the content of b1 ? You might have more data than you think.
-
it is also completed.
compared data n read data both are same
even it is not come into if condition -
if the condition fails it means they are not the same. Maybe a control char like \n that you did not see.
-
hi
what ever I written in the C-Code the same thing is written in GUI even also if() condition is not satisfied.Can I add anything more to that string.....
-
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();
-
sorry for the late reply and thanks for your valuable suggetions I found the solution for this
-
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 :)
-
I am comparing the hexadecimal data directly so it is working.
like if(b1.toHex()==QByteArray(text).toHex())
it is working.