How to use the Qtreewidget Finditem in Pyqt ?

Asked

Viewed 143 times

1

I have a tree QTreeWidget with several previously included items. I need to search for a string x has the same text value as mine QTreeWidgetItem, or I need to check all items in my tree. Does anyone know how I can use this method?

Or how I can make mine QTreeWidget can become a list ?

1 answer

1

Try the findItems, method of QTreeWidget:

tree = QtGui.QTreeWidget()
#...
items = tree.findItems("Teste", QtCore.Qt.MatchRecursive, 0)

This produces a list of all items (QTreeWidgetItem) whose text matches the search parameter. There are more search options, take a look at the documentation of the method, mainly in the values of MatchFlag.

  • Thank you very much C. E. Gesser. I had used findItems but did not know which Matchflag to use. I will give a read in the documentation of the method I am reading a lot and in the values of Matchflag as well. Again Thank You ! : D

Browser other questions tagged

You are not signed in. Login or sign up in order to post.