When I supply QString::compare with two strings:
for(int i = 0; i < ui->tableWidget->rowCount(); i++
{
// assuming searchDialog is a custom-made class with method getResultMap
QMap<QString, int> result = searchDialog->getResultMap();
QString phrase = result.keys().at(0);
int itemFound = 1;
if(itemFound == QString::compare(ui->tableWidget->item(i, searchByColumn)->text(),
phrase,
Qt::CaseInsensitive)) == 0)
{
// Enters here even though the strings differ
}
}
It always returns 0 even though the strings are e.g:
"Car"
"Horse"
"Human"
However when I do such condition:
if(ui->tableWidget->item(i, searchByColumn)->text() == phrase)
{
qDebug() << "Entered the condition";
}
Than the strings appear to be different (it does not enter the condition).
What could be the possible reason?