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. Clarification for asymetry of contains(), indexOf() and filter() for QStringList needed
Qt 6.11 is out! See what's new in the release blog

Clarification for asymetry of contains(), indexOf() and filter() for QStringList needed

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 814 Views 1 Watching
  • 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.
  • S Offline
    S Offline
    StefanBruens
    wrote on last edited by
    #1

    Hi,

    qsl.contains("foo") and qls.indexOf("foo") only return true resp >=0 if the list contains the full string (opposed to substring) "foo", whereas qsl.filter("foo") returns a list with all strings matching ".foo.".

    Is this on purpose?

    Anyway, the documentation should mention this difference.

    Regards, Stefan

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2

      Hi, IMO, the documentation is very clear. They are used for different cases.

      If you want to find whether the list contains the string "foo" or not, should use contians().

      If you want to find the index of the string "foo" in the list, you should use indexOf().

      If you want to get all the strings which contains "foo" in the list, you should use filter().

      1 Reply Last reply
      0

      • Login

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