View Full Version : QStringList::contains() not behaving as expected

7th November 2011, 10:21

I have a problem with QStringList::contains() where it does not return the correct value. I honestly don't believe that there will be a bug in this function, thus I can't understand what is going wrong. I do the following:

// Check uniqueness of name:
Qt::CaseSensitivity case_sensitivity = Qt::CaseSensitive;
QStringList string_list = observer->subjectNames();
qDebug() << "string_list: " << string_list;
qDebug() << "Validate against: " << name << " using " << case_sensitivity;
if (string_list.contains(name,case_sensitivity)) {
result |= Duplicate;
qDebug() << "This is a duplicate";

It prints out the following:

string_list: ("D:\Work\Firmware\FirmwareDesigns\DAC_1X_TOP\Suppor ting Items\Associated Folders\DOCS")
Validate against: "D:\Work\Firmware\FirmwareDesigns\DAC_1X_TOP\Suppor ting Items\Associated Folders\Docs" using 1

contains() should return true, however it does not and I never get the "This is a duplicate" printed out.

Any ideas?

7th November 2011, 10:30
You are doing a case sensitive search and the case of Docs doesn't match, one is Docs the other is DOCS.