[PyQt] qTreeWidgetItemIterator : how it works

Baz Walter bazwal at ftml.net
Thu May 29 16:46:36 BST 2014

On 29/05/14 15:40, singhai.nish wrote:
> Thank you for your reply. I have tried this.
> 	iterator = QTreeWidgetItemIterator(self.light_write,
> QTreeWidgetItemIterator.All)
> 	while iterator.value():
> 		print iterator.value()
> 		iterator+=1
> self.light_write  <PyQt4.QtGui.QTreeWidget object at 0x10c39218>
>   iterator  <PyQt4.QtGui.QTreeWidgetItemIterator object at 0xf66caa0>
> ( There is content to read. ). I am certainly missing something. I don't
> know. It also means I don't know how to think
> like python does. Any help

You haven't actually said what the problem is. The above code works as 
expected for me (i.e. it prints the repr of each tree-widget item). Are 
you trying to print the text of each item? If so, then do:

         item = iterator.value()
         print item.text(0)

Baz Walter

More information about the PyQt mailing list