Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Find an occurrence in a QList

Find an occurrence in a QList

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 512 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    achicour
    wrote on last edited by
    #1

    Hello,
    im looking to find a way of an occurance of a string inside a QList<Qstring>.
    this is what i did:

    i declare a string str1
    i have a QList of strings List1 where i stock some QStrings that i receive.
    and i use the the methode contains as i do here: list1.contains(str1)
    but i dont know if i it returns true for the exact match or just a substring .

    thank you.

    1 Reply Last reply
    0
    • tom8oeT Offline
      tom8oeT Offline
      tom8oe
      wrote on last edited by
      #2

      QList.contains() should only return true for case sensitive exact matches.

      QString strInstance = QString("Quick Test");
      
      listOStrings.append(strInstance);
      
      listOStrings.contains("Quick") // Returns False
      listOStrings.contains("quick test") // Returns False
      listOStrings.contains("Quick Test") // Returns True
      listOStrings.contains(strInstance) // Returns True
      

      Hope this helps.

      1 Reply Last reply
      5

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved