.BI "\fBQListViewItemIterator\fR ( QListView * lv, int iteratorFlags )"
.br
.ti -1c
.BI "QListViewItemIterator & \fBoperator=\fR ( const QListViewItemIterator & it )"
.br
.ti -1c
.BI "\fB~QListViewItemIterator\fR ()"
.br
.ti -1c
.BI "QListViewItemIterator & \fBoperator++\fR ()"
.br
.ti -1c
.BI "const QListViewItemIterator \fBoperator++\fR ( int )"
.br
.ti -1c
.BI "QListViewItemIterator & \fBoperator+=\fR ( int j )"
.br
.ti -1c
.BI "QListViewItemIterator & \fBoperator--\fR ()"
.br
.ti -1c
.BI "const QListViewItemIterator \fBoperator--\fR ( int )"
.br
.ti -1c
.BI "QListViewItemIterator & \fBoperator-=\fR ( int j )"
.br
.ti -1c
.BI "QListViewItem * \fBoperator*\fR ()"
.br
.ti -1c
.BI "QListViewItem * \fBcurrent\fR () const"
.br
.in -1c
.SH DESCRIPTION
The QListViewItemIterator class provides an iterator for collections of QListViewItems.
.PP
Construct an instance of a QListViewItemIterator, with either a QListView* or a QListViewItem* as argument, to operate on the tree of QListViewItems, starting from the argument.
.PP
A QListViewItemIterator iterates over all the items from its starting point. This means that it always makes the first child of the current item the new current item. If there is no child, the next sibling becomes the new current item; and if there is no next sibling, the next sibling of the parent becomes current.
.PP
The following example creates a list of all the items that have been selected by the user, storing pointers to the items in a QPtrList:
.PP
.nf
.br
QPtrList<QListViewItem> lst;
.br
QListViewItemIterator it( myListView );
.br
while ( it.current() ) {
.br
if ( it.current()->isSelected() )
.br
lst.append( it.current() );
.br
++it;
.br
}
.br
.fi
.PP
An alternative approach is to use an IteratorFlag:
A QListViewItemIterator provides a convenient and easy way to traverse a hierarchical QListView.
.PP
Multiple QListViewItemIterators can operate on the tree of QListViewItems. A QListView knows about all iterators operating on its QListViewItems. So when a QListViewItem gets removed all iterators that point to this item are updated and point to the following item if possible, otherwise to a valid item before the current one or to 0. Note however that deleting the parent item of an item that an iterator points to is not safe.
.PP
See also QListView, QListViewItem, and Advanced Widgets.
.SS "Member Type Documentation"
.SH "QListViewItemIterator::IteratorFlag"
These flags can be passed to a QListViewItemIterator constructor (OR-ed together if more than one is used), so that the iterator will only iterate over items that match the given flags.
Constructs an iterator for the QListView that contains the \fIitem\fR. The current iterator item is set to point to the \fIitem\fR.
.SH "QListViewItemIterator::QListViewItemIterator ( QListViewItem * item, int iteratorFlags )"
Constructs an iterator for the QListView that contains the \fIitem\fR using the flags \fIiteratorFlags\fR. The current iterator item is set to point to \fIitem\fR or the next matching item if \fIitem\fR doesn't match the flags.
.PP
See also QListViewItemIterator::IteratorFlag.
.SH "QListViewItemIterator::QListViewItemIterator ( const QListViewItemIterator & it )"
Constructs an iterator for the same QListView as \fIit\fR. The current iterator item is set to point on the current item of \fIit\fR.
Constructs an iterator for the QListView \fIlv\fR. The current iterator item is set to point on the first child (QListViewItem) of \fIlv\fR.
.SH "QListViewItemIterator::QListViewItemIterator ( QListView * lv, int iteratorFlags )"
Constructs an iterator for the QListView \fIlv\fR with the flags \fIiteratorFlags\fR. The current iterator item is set to point on the first child (QListViewItem) of \fIlv\fR that matches the flags.
Prefix ++. Makes the next item the new current item and returns it. Returns 0 if the current item is the last item or the QListView is 0.
.SH "const QListViewItemIterator QListViewItemIterator::operator++ ( int )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Postfix ++. Makes the next item the new current item and returns the item that \fIwas\fR the current item.
.SH "QListViewItemIterator & QListViewItemIterator::operator+= ( int j )"
Sets the current item to the item \fIj\fR positions after the current item. If that item is beyond the last item, the current item is set to 0. Returns the current item.
Prefix --. Makes the previous item the new current item and returns it. Returns 0 if the current item is the first item or the QListView is 0.
.SH "const QListViewItemIterator QListViewItemIterator::operator-- ( int )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Postfix --. Makes the previous item the new current item and returns the item that \fIwas\fR the current item.
.SH "QListViewItemIterator & QListViewItemIterator::operator-= ( int j )"
Sets the current item to the item \fIj\fR positions before the current item. If that item is before the first item, the current item is set to 0. Returns the current item.
.SH "QListViewItemIterator & QListViewItemIterator::operator= ( const QListViewItemIterator & it )"
Assignment. Makes a copy of \fIit\fR and returns a reference to its