QListViewItemIterator(3qt)

πŸ“¦ version 3.3.8b, in fedora 43, fedora 44

πŸ’– QListViewItemIterator πŸ’–

okay bestie, welcome to the qlistviewitemiterator.3qt manual page, but make it cute. this is the iterator for collections of QListViewItems and honestly? she's a whole vibe. ✨


🌸 NAME 🌸

QListViewItemIterator β€” iterator for collections of QListViewItems πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

first things first, you gotta let the compiler know:

#include <qlistview.h>

πŸ¦‹ Public Members πŸ¦‹

the enum, in all her glory (hex values and everything, no cap):

enum IteratorFlag { Visible = 0x00000001, Invisible = 0x00000002,
    Selected = 0x00000004, Unselected = 0x00000008, Selectable =
    0x00000010, NotSelectable = 0x00000020, DragEnabled = 0x00000040,
    DragDisabled = 0x00000080, DropEnabled = 0x00000100, DropDisabled =
    0x00000200, Expandable = 0x00000400, NotExpandable = 0x00000800,
    Checked = 0x00001000, NotChecked = 0x00002000 }

and the rest of the squad:

  • QListViewItemIterator ()
  • QListViewItemIterator ( QListViewItem * item )
  • QListViewItemIterator ( QListViewItem * item, int iteratorFlags )
  • QListViewItemIterator ( const QListViewItemIterator & it )
  • QListViewItemIterator ( QListView * lv )
  • QListViewItemIterator ( QListView * lv, int iteratorFlags )
  • QListViewItemIterator & operator= ( const QListViewItemIterator & it )
  • ~QListViewItemIterator ()
  • QListViewItemIterator & operator++ ()
  • const QListViewItemIterator operator++ ( int )
  • QListViewItemIterator & operator+= ( int j )
  • QListViewItemIterator & operator-- ()
  • const QListViewItemIterator operator-- ( int )
  • QListViewItemIterator & operator-= ( int j )
  • QListViewItem * operator* ()
  • QListViewItem * current () const

✨ DESCRIPTION ✨

so the QListViewItemIterator class provides an iterator for collections of QListViewItems. that's the whole job. she iterates. she serves. πŸ’…

you construct an instance of a QListViewItemIterator with either a QListView* or a QListViewItem* as the argument, and then you're operating on the tree of QListViewItems, starting from whatever you handed her. 🫢

here's the tea on how she walks the tree: a QListViewItemIterator iterates over all the items from its starting point. that means she always makes the first child of the current item the new current item. no child? then the next sibling becomes the new current item. no next sibling either? then the next sibling of the parent becomes current. it's giving "keep the line moving" energy fr fr. 🌈

example time β€” this one builds a list of everything the user selected, and stashes the pointers in a QPtrList:

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

but wait, there's a glow-up: an alternative approach is to use an IteratorFlag instead πŸ‘‘

QPtrList<QListViewItem> lst;
QListViewItemIterator it( myListView, QListViewItemIterator::Selected );
while ( it.current() ) {
    lst.append( it.current() );
    ++it;
}

see how much cleaner that is?? obsessed. 😭

basically a QListViewItemIterator provides a convenient and easy way to traverse a hierarchical QListView. iconic behavior.

now, plot twist: multiple QListViewItemIterators can operate on the tree of QListViewItems at the same time. 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. the group chat stays in sync. πŸ’–

🚨 but listen carefully bestie: deleting the parent item of an item that an iterator points to is not safe. don't do it. i'm serious. πŸ’€

See also: QListView, QListViewItem, and Advanced Widgets.

🌟 Member Type Documentation 🌟

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. filter your feed, basically. πŸŽ€

and here's the full roll call β€” the original page lists them all with no extra commentary, so i'm doing the same, but cuter:

  • QListViewItemIterator::Visible
  • QListViewItemIterator::Invisible
  • QListViewItemIterator::Selected
  • QListViewItemIterator::Unselected
  • QListViewItemIterator::Selectable
  • QListViewItemIterator::NotSelectable
  • QListViewItemIterator::DragEnabled
  • QListViewItemIterator::DragDisabled
  • QListViewItemIterator::DropEnabled
  • QListViewItemIterator::DropDisabled
  • QListViewItemIterator::Expandable
  • QListViewItemIterator::NotExpandable
  • QListViewItemIterator::Checked
  • QListViewItemIterator::NotChecked

fourteen flags. all accounted for. periodt. πŸ’…


πŸ’œ MEMBER FUNCTION DOCUMENTATION πŸ’œ

QListViewItemIterator::QListViewItemIterator ()

Constructs an empty iterator. she's just a girl. standing in front of a tree. with nothing in her. πŸ¦‹

QListViewItemIterator::QListViewItemIterator ( QListViewItem * item )

Constructs an iterator for the QListView that contains the item. the current iterator item is set to point to the item. 🎯

QListViewItemIterator::QListViewItemIterator ( QListViewItem * item, int iteratorFlags )

Constructs an iterator for the QListView that contains the item, using the flags iteratorFlags. the current iterator item is set to point to item β€” or the next matching item if item doesn't match the flags. picky, but in a good way. ✨

See also: QListViewItemIterator::IteratorFlag.

QListViewItemIterator::QListViewItemIterator ( const QListViewItemIterator & it )

Constructs an iterator for the same QListView as it. the current iterator item is set to point on the current item of it. twin behavior. πŸ‘―

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. starting from the top, main character energy. πŸ‘‘

QListViewItemIterator::QListViewItemIterator ( QListView * lv, int iteratorFlags )

Constructs an iterator for the QListView lv with the flags iteratorFlags. the current iterator item is set to point on the first child (QListViewItem) of lv that matches the flags. she's selective. she has standards. πŸ’…

See also: QListViewItemIterator::IteratorFlag.

QListViewItemIterator::~QListViewItemIterator ()

Destroys the iterator. bye bestie, thank you for your service 🫢

QListViewItem * QListViewItemIterator::current () const

Returns iterator's current item.

Examples:

(yep β€” that's literally all the original says here. the examples section is empty. i'm not making anything up, that's just how it is. 😭)

QListViewItem * QListViewItemIterator::operator* ()

Dereference operator. Returns a reference to the current item. The same as current(). same energy, different syntax. ⭐

QListViewItemIterator & QListViewItemIterator::operator++ ()

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. moving on up, no notes. πŸ”₯

const QListViewItemIterator QListViewItemIterator::operator++ ( int )

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

Postfix ++. Makes the next item the new current item and returns the item that was the current item. she remembers where she came from, lowkey sentimental. πŸ₯Ί

QListViewItemIterator & QListViewItemIterator::operator+= ( int j )

Sets the current item to the item j positions after the current item. If that item is beyond the last item, the current item is set to 0. Returns the current item. big jump, big lewk. πŸ¦‹

QListViewItemIterator & QListViewItemIterator::operator-- ()

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. going back, rewinding the tape. πŸŽ€

const QListViewItemIterator QListViewItemIterator::operator-- ( int )

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

Postfix --. Makes the previous item the new current item and returns the item that was the current item. πŸ’–

QListViewItemIterator & QListViewItemIterator::operator-= ( int j )

Sets the current item to the item j positions before the current item. If that item is before the first item, the current item is set to 0. Returns the current item. ✨

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

Assignment. Makes a copy of it and returns a reference to its iterator. copy-paste but make it official. πŸ’…


🌈 SEE ALSO 🌈


Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.


🌸 AUTHOR 🌸

Generated automatically from the source code. (so no, a human didn't hand-write this one β€” the robots did it, and honestly? respect. πŸ€–βœ¨)


πŸ’€ BUGS πŸ’€

If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. (fr fr, they mean it β€” a good bug report is a love letter to the maintainers 🫢)

The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech.

If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qlistviewitemiterator.3qt) and the Qt version (3.3.8).


okay that's the whole page, bestie, you ate that. πŸ’…βœ¨ this cutie little manual came from Trolltech AS, dated 2 February 2007, and it's chillin' in the 3.3.8 Qt era as qlistviewitemiterator.3qt. mwah, go iterate something gorgeous. πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from