parulkalra14
27th January 2014, 11:42
I want whenever if (while ()) comes it will print Checking condition for If Statement and whenever while (if ()) comes it will print Checking condition for While Statement. I tried this code:
if(cursor.block().text().contains("while",Qt::CaseInsensitive)&& cursor.block().text().contains("(",Qt::CaseInsensitive))
{
ui->label->setText("Checking condition for While Statement");
}
if(cursor.block().text().contains("if",Qt::CaseInsensitive)&&cursor.block().text().contains("(",Qt::CaseInsensitive))
{
ui->label->setText("Checking condition for If Statement");
}
when i entered only if () and only while () then it gives Checking condition for If Statement and Checking condition for While Statement respectively. But when i entered if (while ()) and while (if ()), it gives Checking condition for If Statement in both the cases.
if(cursor.block().text().contains("while",Qt::CaseInsensitive)&& cursor.block().text().contains("(",Qt::CaseInsensitive))
{
ui->label->setText("Checking condition for While Statement");
}
if(cursor.block().text().contains("if",Qt::CaseInsensitive)&&cursor.block().text().contains("(",Qt::CaseInsensitive))
{
ui->label->setText("Checking condition for If Statement");
}
when i entered only if () and only while () then it gives Checking condition for If Statement and Checking condition for While Statement respectively. But when i entered if (while ()) and while (if ()), it gives Checking condition for If Statement in both the cases.