Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get QListWidget item by name?

I have a QListWidget which displays a list of names using PyQt in Python. How can I get the QListWidgetItem for a given name?

For example, if I have the following QListWidget with 4 items, how can I get the item which contains text = dan?

QListWidget

like image 361
panofish Avatar asked Jun 26 '14 14:06

panofish


1 Answers

The python equivalent to vahancho's answer:

items = self.listWidgetName.findItems("dan",Qt.MatchExactly)

if len(items) > 0:

    for item in items:
        print "row number of found item =",self.listWidgetName.row(item)
        print "text of found item =",item.text() 
like image 52
panofish Avatar answered Sep 24 '22 08:09

panofish