Results 1 to 2 of 2

Thread: caseinsensitive qstringlist

  1. #1
    Join Date
    Jun 2009
    Posts
    74
    Thanks
    23
    Thanked 2 Times in 2 Posts

    Default caseinsensitive qstringlist

    Hi ,

    How can I create a caseinsensitive qstringlist?

    Qt Code:
    1. QStringList sl(...) ; //suppose it is case insensitive
    2.  
    3.  
    4. sl<<"hello";
    5. sl<<"Hello";
    6. sl<<"HELLO";
    To copy to clipboard, switch view to plain text mode 

    So if I execute sl.remove("hello");
    all items above will be removed from sl

    Thanks

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: caseinsensitive qstringlist

    QStringList itself doesn't do that, but you could use the filter() functions. They allow you to set case sensitivity. However, you would need to use a negative regexp: everything not matching "hello" should be returned. Of course you could also filter out everything that matches hello and then run through that list to remove it from the original list...

    Unfortunately both options don't really give you a case insensitive list.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

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

    hashb (21st December 2010)

Similar Threads

  1. Plz help me,I met a bug about QStringList
    By study_c in forum Qt Programming
    Replies: 1
    Last Post: 16th October 2010, 16:56
  2. QString::indexOf Qt::CaseInsensitive
    By Carlsberg in forum Qt Programming
    Replies: 3
    Last Post: 19th May 2009, 19:11
  3. QStringList
    By jaca in forum Qt Programming
    Replies: 5
    Last Post: 17th May 2008, 11:12
  4. QStringList
    By dragon in forum Newbie
    Replies: 2
    Last Post: 8th June 2007, 18:26
  5. Replies: 7
    Last Post: 2nd June 2006, 13:48

Tags for this Thread

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.