PDA

View Full Version : QTreeWidgetItemIterator with python



rosmarcha
6th September 2006, 17:16
Hi,

I'm wondering how to use the iterator widget in python?.

oIterWidget = QtGui.QTreeWidgetItemIterator(self.tocTL)
...

looking for a simple example
Thanks.

rosmarcha
6th September 2006, 17:59
Hi,

I'm looking for a way to iterate thru all of the QTreeWidgetItem of a qTreeWidget in python?

Basically i need to expand all of the widget items on first view, i only have 1 column

thanks,

jacek
6th September 2006, 18:19
QTreeWidgetItemIterator is not a widget, it's an iterator. You can use it to iterate over a collection of QTreeWidgetItems.

Unfortunately there isn't much information about it in PyQt docs. You can use it += 1 to move to another element and it.value() to access the QTreeWidgetItem. The question is how do you know if you reached the last item?

I don't have PyQt installed, but judging from the original Qt docs, probably you can do it like this:

while it.value():
doSomethingWithItem( it.value() )
it += 1