[PyKDE] iterating over a QListView
Christopher J. Bottaro
cjbottaro at alumni.cs.utexas.edu
Tue Feb 22 19:35:52 GMT 2005
The C++ documentation shows this example:
QPtrList<QListViewItem> lst;
QListViewItemIterator it( myListView );
while ( it.current() ) {
if ( it.current()->isSelected() )
lst.append( it.current() );
++it;
I'm wondering if there is a Pythonic way of doing this. Maybe something
like:
lst = []
for listviewitem in listview:
if listviewitem.isSelected():
lst.append(listviewitem)
or maybe:
lst = []
for listviewitem in QListViewItemIterator(listview):
if listviewitem.isSelected():
lst.append(listviewitem)
Or is there no Pythonic way and I just have to translate the C++ directly?
This question goes for all Qt iterator classes (i.e. are they turned into
Python iterables by PyQt?).
Thanks for the help.
More information about the PyQt
mailing list