返回介绍

QListViewItemIterator Class

发布于 2019-10-04 15:01:09 字数 5859 浏览 1039 评论 0 收藏 0

The QListViewItemIterator class provides an iterator for collections of QListViewItems. More...

#include <qlistview.h>

List of all member functions.

Public Members

  • QListViewItemIterator ()
  • QListViewItemIterator ( QListViewItem*item )
  • QListViewItemIterator ( constQListViewItemIterator&it )
  • QListViewItemIterator ( QListView*lv )
  • QListViewItemIterator & operator= ( constQListViewItemIterator&it )
  • ~QListViewItemIterator ()
  • QListViewItemIterator & operator++ ()
  • const QListViewItemIterator operator++ ( int )
  • QListViewItemIterator & operator+= ( intj )
  • QListViewItemIterator & operator-- ()
  • const QListViewItemIterator operator-- ( int )
  • QListViewItemIterator & operator-= ( intj )
  • QListViewItem * current () const

Detailed Description

The QListViewItemIterator class provides an iterator for collections of QListViewItems.

Construct an instance of a QListViewItemIterator, with either a QListView* or a QListViewItem* as argument, to operate on the tree of QListViewItems.

A QListViewItemIterator iterates over all items of a list view. 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.

The following example function gets a list of all the items that have been selected by the user, storing pointers to the items in a QPtrList:

    QPtrList<QListViewItem> lst;
    QListViewItemIterator it( lv );
    while ( it.current() != 0 ) {
        if ( it.current()->isSelected() )
            lst.append( it.current() );
        ++it;
    }
  

A QListViewItemIterator provides a convenient and easy way to traverse a hierarchical QListView.

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.

See also QListView, QListViewItem and Advanced Widgets.


Member Function Documentation

QListViewItemIterator::QListViewItemIterator ()

Constructs an empty iterator.

QListViewItemIterator::QListViewItemIterator ( QListViewItem*item )

Constructs an iterator for the QListView of the item. The current iterator item is set to point to the item.

QListViewItemIterator::QListViewItemIterator ( constQListViewItemIterator&it )

Constructs an iterator for the same QListView as it. The current iterator item is set to point on the current item of it.

QListViewItemIterator::QListViewItemIterator ( QListView*lv )

Constructs an iterator for the QListView lv. The current iterator item is set to point on the first child (QListViewItem) of lv.

QListViewItemIterator::~QListViewItemIterator ()

Destroys the iterator.

QListViewItem* QListViewItemIterator::current () const

Returns a pointer to the current item of the iterator.

Examples: addressbook/centralwidget.cpp, checklists/checklists.cpp, dirview/dirview.cpp and network/ftpclient/ftpview.cpp.

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.

constQListViewItemIterator QListViewItemIterator::operator++ ( int )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Postfix ++ makes the next item in the QListViewItem tree of the QListView of the iterator the current item and returns the item which was previously current.

QListViewItemIterator& QListViewItemIterator::operator+= ( intj )

Sets the current item to the item j positions after the current item in the QListViewItem hierarchy. If this item is beyond the last item, the current item is set to null.

The new current item (or null, if the new current item is null) is returned.

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.

constQListViewItemIterator QListViewItemIterator::operator-- ( int )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Postfix -- makes the previous item in the QListViewItem tree of the QListView of the iterator the current item and returns the item.

QListViewItemIterator& QListViewItemIterator::operator-= ( intj )

Sets the current item to the item j positions before the current item in the QListViewItem hierarchy. If this item is before 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.

QListViewItemIterator& QListViewItemIterator::operator= ( constQListViewItemIterator&it )

Assignment. Makes a copy of it and returns a reference to its iterator.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文