📄 qlistviewitemiterator.3qt
字号:
.TH QListViewItemIterator 3qt "10 November 2000" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2000 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQListViewItemIterator \- Iterator for collections of QListViewItems.SH SYNOPSIS.br.PP\fC#include <qlistview.h>\fR.PP.SS "Public Members".in +1c.ti -1c.BI "\fBQListViewItemIterator\fR () ".br.ti -1c.BI "\fBQListViewItemIterator\fR ( QListViewItem * item ) ".br.ti -1c.BI "\fBQListViewItemIterator\fR ( const QListViewItemIterator & it ) ".br.ti -1c.BI "\fBQListViewItemIterator\fR ( QListView * lv ) ".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* \fBcurrent\fR () const".br.in -1c.SH DESCRIPTIONThe QListViewItemIterator class provides an iterator for collections of QListViewItems.PPConstruct an instance of a QListViewItemIterator with either a QListView* or a QListViewItem* as argument, to operate on the tree of QListViewItems..PPA QListViewItemIterator iterates over all items of a listview. This means ++it makes always the first child of the current item the new current one. If there is no child, the next sibling gets the new current item, and if there is no next sibling, the next sibling of the parent is set to current..PPExample:.PPOften you want to get all items, which were selected by a user. Here is an example which does this and stores the pointers to all selected items in a QList..PP.nf.br // Somewhere a listview is generated like this.br QListView *lv = new QListView(this);.br // Enable multiselection.br lv->setMultiSelection( TRUE );.br.br // Insert the items here.br.br // ....br.br // This function is called to get a list of the selected items of a listview.br QList<QListViewItem> * getSelectedItems( QListView *lv ) {.br if ( !lv ).br return 0;.br.br // Create the list.br QList<QListViewItem> *lst = new QList<QListViewItem>;.br lst->setAutoDelete( FALSE );.br.br // Create an iterator and give the listview as argument.br QListViewItemIterator it( lv );.br // iterate through all items of the listview.br for ( ; it.current(); ++it ) {.br if ( it.current()->isSelected() ).br lst->append( it.current() );.br }.br.br return lst;.br }.fi.PPUsing a QListViewItemIterator is a convenient way to traverse the tree of QListViewItems of a QListView. It makes especially operating on a hierarchical QListView easy..PPAlso, multiple QListViewItemIterators can operate on the tree of QListViewItems. A QListView knows about all iterators which are operating on its QListViewItems. So when a QListViewItem gets removed, all iterators that point to this item get updated and point to the new current item after that..PPSee also QListView and QListViewItem..SH MEMBER FUNCTION DOCUMENTATION.SH "QListViewItemIterator::QListViewItemIterator ()"Constructs an empty iterator..SH "QListViewItemIterator::QListViewItemIterator ( QListView * lv )"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 ( QListViewItem * item )"Constructs an iterator for the QListView of the \fIitem.\fR The current iterator item is set to point on the \fIitem.\fR.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.SH "QListViewItemIterator::~QListViewItemIterator ()"Destroys the iterator..SH "QListViewItem * QListViewItemIterator::current () const"Returns a pointer to the current item of the iterator..SH "QListViewItemIterator & QListViewItemIterator::operator++ ()"Prefix ++ makes the next item in the QListViewItem tree of the QListView of the iterator the current item and returns it. If the current item was the last item in the QListView or null, null is returned..SH "const QListViewItemIterator QListViewItemIterator::operator++ ( int )"Postfix ++ makes the next item in the QListViewItem tree of the QListView of the iterator the current item and returns the item, which was the current one before..SH "QListViewItemIterator & QListViewItemIterator::operator+= ( int j )"Sets the current item to the item \fIj\fR positions after the current item in the QListViewItem hierarchy. If this item is beyond the last item, the current item is set to null..PPThe new current item (or null, if the new current item is null) is returned..SH "QListViewItemIterator & QListViewItemIterator::operator-- ()"Prefix -- makes the previous item in the QListViewItem tree of the QListView of the iterator the current item and returns it. If the current item was the last first in the QListView or null, null is returned..SH "const QListViewItemIterator QListViewItemIterator::operator-- ( int )"Postfix -- makes the previous item in the QListViewItem tree of the QListView of the iterator the current item and returns the item, which was the current one before..SH "QListViewItemIterator & QListViewItemIterator::operator-= ( int j )"Sets the current item to the item \fIj\fR positions before the current item in the QListViewItem hierarchy. If this item is above the first item, the current item is set to null. The new current item (or null, if the new current item is null) is returned..SH "QListViewItemIterator & QListViewItemIterator::operator= ( const QListViewItemIterator & it )"Assignment. Makes a copy of \fIit\fR and returns a reference to itsiterator..SH "SEE ALSO".BR http://doc.trolltech.com/qlistviewitemiterator.html.SH COPYRIGHTCopyright 1992-2000 Trolltech AS, http://www.trolltech.com/. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -