Search code examples
pythonpyqt4graphic

How find a Item of QListWidget with findItem?


How find a Item of QListWidget with findItem, set a String "Example". How do it bottom ?

   if QlistWidget HAVE a "String Example":
           return True
   else:
           return False

Thanks!


Solution

  • This is in the documentation:

    out = lw.findItems("String Example", QtCore.Qt.MatchExactly)
    return len(out) > 0
    

    where lw is your QListWidget. out is a list of matching items.