I have a QHash<QString,QString>
.
I use the following expression to check whether a value is there in the QHash::keys()
or not.
//programme
QHash<QString,QString> samplehash;
QString value = "somevalue";
if(samplehash.contains(value)) // Condition - 1
{
//some code
}
Sometimes the above conditions matches, sometimes not for the same letters of different case. Is the QHash::contains
method case-sensitive?
QHash.contains()
is case sensitive as John T mentioned. Without the code there is not much to figure out. You can imagine it doing a ==
between the keys.
Please do not forget that accessing a non existent element via []
will create an empty entry in the hash, this might be what causes your bug. contains
does not insert an entry into the hash, neither does value