munna
16th June 2006, 10:50
Hi,
I am using Qt 3 and trying a parse a string entered by the user. For this i am extracting each character and playing with it. The problem is when i try to compare a QString which is contains "-" with "-" the result is false.
Has someone encountered this kind of problem ? Am I doing something wrong? Here is the code:
for(pos=0;pos<expr.length();pos++)
{
QString curr = expr.at(pos);
if(curr == ":")
{
OperatorParse("+");
}
else if((curr == QString(QChar(0xD7)))||(curr==QString(QChar(0xDD)) )||
(curr == "+")||(curr == "-")||(curr == "*")||(curr == "/")||(curr == "^"))
{
OperatorParse(curr);
}
else if(curr == "(")
{
LeftParse(0, pos);
}
else if(curr == "{")
{
LeftParse(1, pos);
}
else if(curr == "[")
{
LeftParse(2, pos);
}
else if((curr == ")")||(curr == "}")||(curr == "]"))
{
RightParse();
}
}
expr is the string that i am parsing.
I entered "2 - 2" but the - is not recongnized
Thanks
I am using Qt 3 and trying a parse a string entered by the user. For this i am extracting each character and playing with it. The problem is when i try to compare a QString which is contains "-" with "-" the result is false.
Has someone encountered this kind of problem ? Am I doing something wrong? Here is the code:
for(pos=0;pos<expr.length();pos++)
{
QString curr = expr.at(pos);
if(curr == ":")
{
OperatorParse("+");
}
else if((curr == QString(QChar(0xD7)))||(curr==QString(QChar(0xDD)) )||
(curr == "+")||(curr == "-")||(curr == "*")||(curr == "/")||(curr == "^"))
{
OperatorParse(curr);
}
else if(curr == "(")
{
LeftParse(0, pos);
}
else if(curr == "{")
{
LeftParse(1, pos);
}
else if(curr == "[")
{
LeftParse(2, pos);
}
else if((curr == ")")||(curr == "}")||(curr == "]"))
{
RightParse();
}
}
expr is the string that i am parsing.
I entered "2 - 2" but the - is not recongnized
Thanks