pyqt: multiple selections in QListView

Phil Thompson phil at riverbankcomputing.co.uk
Wed Jul 14 18:52:04 EDT 2004


On Wednesday 14 July 2004 11:38 pm, Bob Parnes wrote:
> On Tue, Jul 13, 2004 at 08:29:07AM +0100, Phil Thompson wrote:
> > On Tuesday 13 July 2004 1:53 am, Bob Parnes wrote:
> > > I cannot find a reference on identifying multiple selections in
> > > QListView. Apparently one has to iterate through all the items and test
> > > each individually, but I don't know how to do the iteration. The qt3
> > > documentation suggests QListViewItemIterator, but this does not seem to
> > > be available in python.
> >
> > QListViewIterator was added to PyQt v3.9 (current version is v3.12).
> >
> > Phil
>
> Thanks very much. I am using v3.8 on a debian computer. I'll try to
> upgrade.

At the moment it could be more Pythonic. You have to do something like...

	it = QListItemViewIterator(list_view)

	itm = it.current()

	while itm:
		# Do something

		it += 1
		itm = it.current()

In a future version I will make QListItemViewIterator behave like a Python 
iterator so that you do this instead...

	for itm in QListItemViewIterator(list_view):
		# Do something

Phil



More information about the Python-list mailing list