Results 1 to 2 of 2

Thread: QStringList::contains() not behaving as expected

  1. #1
    Join Date
    Aug 2008
    Posts
    132
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default QStringList::contains() not behaving as expected

    Hi

    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:

    Qt Code:
    1. // Check uniqueness of name:
    2. Qt::CaseSensitivity case_sensitivity = Qt::CaseSensitive;
    3. QStringList string_list = observer->subjectNames();
    4. qDebug() << "string_list: " << string_list;
    5. qDebug() << "Validate against: " << name << " using " << case_sensitivity;
    6. if (string_list.contains(name,case_sensitivity)) {
    7. result |= Duplicate;
    8. qDebug() << "This is a duplicate";
    9. }
    To copy to clipboard, switch view to plain text mode 

    It prints out the following:
    Qt Code:
    1. string_list: ("D:\Work\Firmware\FirmwareDesigns\DAC_1X_TOP\Supporting Items\Associated Folders\DOCS")
    2. Validate against: "D:\Work\Firmware\FirmwareDesigns\DAC_1X_TOP\Supporting Items\Associated Folders\Docs" using 1
    To copy to clipboard, switch view to plain text mode 

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

    Any ideas?
    Thanks
    Jaco

  2. #2
    Join Date
    Dec 2008
    Location
    France
    Posts
    93
    Thanked 23 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: QStringList::contains() not behaving as expected

    You are doing a case sensitive search and the case of Docs doesn't match, one is Docs the other is DOCS.

  3. The following user says thank you to nix for this useful post:

    JPNaude (7th November 2011)

Similar Threads

  1. Derived class from QLineEdit is behaving differently.
    By savaliya_ambani in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 21st January 2011, 08:40
  2. QLineEdit not updating as expected
    By Ishtar in forum Newbie
    Replies: 2
    Last Post: 28th April 2010, 12:09
  3. expected `)' before '*' token
    By vinod sharma in forum Qt Programming
    Replies: 3
    Last Post: 15th March 2010, 07:57
  4. Modal dialog not behaving
    By tpf80 in forum Qt Programming
    Replies: 7
    Last Post: 16th September 2008, 22:03
  5. Replies: 7
    Last Post: 2nd June 2006, 12:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.