Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QTreeWidgetItemIterator Class Reference

\inmodule QtWidgets More...

#include <qtreewidgetitemiterator.h>

+ Collaboration diagram for QTreeWidgetItemIterator:

Public Types

enum  IteratorFlag {
  All = 0x00000000 , Hidden = 0x00000001 , NotHidden = 0x00000002 , Selected = 0x00000004 ,
  Unselected = 0x00000008 , Selectable = 0x00000010 , NotSelectable = 0x00000020 , DragEnabled = 0x00000040 ,
  DragDisabled = 0x00000080 , DropEnabled = 0x00000100 , DropDisabled = 0x00000200 , HasChildren = 0x00000400 ,
  NoChildren = 0x00000800 , Checked = 0x00001000 , NotChecked = 0x00002000 , Enabled = 0x00004000 ,
  Disabled = 0x00008000 , Editable = 0x00010000 , NotEditable = 0x00020000 , UserFlag = 0x01000000
}
 These flags can be passed to a QTreeWidgetItemIterator constructor (OR-ed together if more than one is used), so that the iterator will only iterate over items that match the given flags. More...
 

Public Member Functions

 QTreeWidgetItemIterator (const QTreeWidgetItemIterator &it)
 Constructs an iterator for the same QTreeWidget as it.
 
 QTreeWidgetItemIterator (QTreeWidget *widget, IteratorFlags flags=All)
 Constructs an iterator for the given widget that uses the specified flags to determine which items are found during iteration.
 
 QTreeWidgetItemIterator (QTreeWidgetItem *item, IteratorFlags flags=All)
 Constructs an iterator for the given item that uses the specified flags to determine which items are found during iteration.
 
 ~QTreeWidgetItemIterator ()
 Destroys the iterator.
 
QTreeWidgetItemIteratoroperator= (const QTreeWidgetItemIterator &it)
 Assignment.
 
QTreeWidgetItemIteratoroperator++ ()
 The prefix {++} operator ({++it}) advances the iterator to the next matching item and returns a reference to the resulting iterator.
 
const QTreeWidgetItemIterator operator++ (int)
 The postfix ++ operator (it++) advances the iterator to the next matching item and returns an iterator to the previously current item.
 
QTreeWidgetItemIteratoroperator+= (int n)
 Makes the iterator go forward by n matching items.
 
QTreeWidgetItemIteratoroperator-- ()
 The prefix {–} operator ({–it}) advances the iterator to the previous matching item and returns a reference to the resulting iterator.
 
const QTreeWidgetItemIterator operator-- (int)
 The postfix – operator (it–) makes the preceding matching item current and returns an iterator to the previously current item.
 
QTreeWidgetItemIteratoroperator-= (int n)
 Makes the iterator go backward by n matching items.
 
QTreeWidgetItemoperator* () const
 Dereference operator.
 

Friends

class QTreeModel
 

Detailed Description

\inmodule QtWidgets

The QTreeWidgetItemIterator class provides a way to iterate over the items in a QTreeWidget instance.

The iterator will walk the items in a pre-order traversal order, thus visiting the parent node before it continues to the child nodes.

For example, the following code examples each item in a tree, checking the text in the first column against a user-specified search string:

while (*it) {
if ((*it)->text(0) == itemText)
(*it)->setSelected(true);
++it;
}

It is also possible to filter out certain types of node by passing certain \l{IteratorFlag}{flags} to the constructor of QTreeWidgetItemIterator.

See also
QTreeWidget, {Model/View Programming}, QTreeWidgetItem

Definition at line 19 of file qtreewidgetitemiterator.h.

Member Enumeration Documentation

◆ IteratorFlag

These flags can be passed to a QTreeWidgetItemIterator constructor (OR-ed together if more than one is used), so that the iterator will only iterate over items that match the given flags.

\value All \value Hidden \value NotHidden \value Selected \value Unselected \value Selectable \value NotSelectable \value DragEnabled \value DragDisabled \value DropEnabled \value DropDisabled \value HasChildren \value NoChildren \value Checked \value NotChecked \value Enabled \value Disabled \value Editable \value NotEditable \value UserFlag

Enumerator
All 
Hidden 
NotHidden 
Selected 
Unselected 
Selectable 
NotSelectable 
DragEnabled 
DragDisabled 
DropEnabled 
DropDisabled 
HasChildren 
NoChildren 
Checked 
NotChecked 
Enabled 
Disabled 
Editable 
NotEditable 
UserFlag 

Definition at line 24 of file qtreewidgetitemiterator.h.

Constructor & Destructor Documentation

◆ QTreeWidgetItemIterator() [1/3]

QTreeWidgetItemIterator::QTreeWidgetItemIterator ( const QTreeWidgetItemIterator & it)

Constructs an iterator for the same QTreeWidget as it.

The current iterator item is set to point on the current item of it.

Definition at line 38 of file qtreewidgetitemiterator.cpp.

References d, and Q_ASSERT.

◆ QTreeWidgetItemIterator() [2/3]

QTreeWidgetItemIterator::QTreeWidgetItemIterator ( QTreeWidget * widget,
IteratorFlags flags = All )
explicit

Constructs an iterator for the given widget that uses the specified flags to determine which items are found during iteration.

The iterator is set to point to the first top-level item contained in the widget, or the next matching item if the top-level item doesn't match the flags.

See also
QTreeWidgetItemIterator::IteratorFlag

Definition at line 56 of file qtreewidgetitemiterator.cpp.

References QObject::children(), QList< T >::isEmpty(), model, Q_ASSERT, QScopedPointer< T, Cleanup >::reset(), and widget.

+ Here is the call graph for this function:

◆ QTreeWidgetItemIterator() [3/3]

QTreeWidgetItemIterator::QTreeWidgetItemIterator ( QTreeWidgetItem * item,
IteratorFlags flags = All )
explicit

Constructs an iterator for the given item that uses the specified flags to determine which items are found during iteration.

The iterator is set to point to item, or the next matching item if item doesn't match the flags.

See also
QTreeWidgetItemIterator::IteratorFlag

Definition at line 78 of file qtreewidgetitemiterator.cpp.

References d, item, model, QTreeWidgetItem::parent(), and Q_ASSERT.

+ Here is the call graph for this function:

◆ ~QTreeWidgetItemIterator()

QTreeWidgetItemIterator::~QTreeWidgetItemIterator ( )

Destroys the iterator.

Definition at line 111 of file qtreewidgetitemiterator.cpp.

Member Function Documentation

◆ operator*()

QTreeWidgetItem * QTreeWidgetItemIterator::operator* ( ) const
inline

Dereference operator.

Returns a pointer to the current item.

Definition at line 105 of file qtreewidgetitemiterator.h.

◆ operator++() [1/2]

QTreeWidgetItemIterator & QTreeWidgetItemIterator::operator++ ( )

The prefix {++} operator ({++it}) advances the iterator to the next matching item and returns a reference to the resulting iterator.

Sets the current pointer to \nullptr if the current item is the last matching item.

Definition at line 140 of file qtreewidgetitemiterator.cpp.

◆ operator++() [2/2]

const QTreeWidgetItemIterator QTreeWidgetItemIterator::operator++ ( int )
inline

The postfix ++ operator (it++) advances the iterator to the next matching item and returns an iterator to the previously current item.

Definition at line 73 of file qtreewidgetitemiterator.h.

References it.

◆ operator+=()

QTreeWidgetItemIterator & QTreeWidgetItemIterator::operator+= ( int n)
inline

Makes the iterator go forward by n matching items.

(If n is negative, the iterator goes backward.)

If the current item is beyond the last item, the current item pointer is set to \nullptr. Returns the resulting iterator.

Definition at line 87 of file qtreewidgetitemiterator.h.

◆ operator--() [1/2]

QTreeWidgetItemIterator & QTreeWidgetItemIterator::operator-- ( )

The prefix {–} operator ({–it}) advances the iterator to the previous matching item and returns a reference to the resulting iterator.

Sets the current pointer to \nullptr if the current item is the first matching item.

Definition at line 155 of file qtreewidgetitemiterator.cpp.

◆ operator--() [2/2]

const QTreeWidgetItemIterator QTreeWidgetItemIterator::operator-- ( int )
inline

The postfix – operator (it–) makes the preceding matching item current and returns an iterator to the previously current item.

Definition at line 80 of file qtreewidgetitemiterator.h.

References it.

◆ operator-=()

QTreeWidgetItemIterator & QTreeWidgetItemIterator::operator-= ( int n)
inline

Makes the iterator go backward by n matching items.

(If n is negative, the iterator goes forward.)

If the current item is ahead of the last item, the current item pointer is set to \nullptr. Returns the resulting iterator.

Definition at line 96 of file qtreewidgetitemiterator.h.

◆ operator=()

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

Assignment.

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

Definition at line 121 of file qtreewidgetitemiterator.cpp.

References d, and it.

Friends And Related Symbol Documentation

◆ QTreeModel

friend class QTreeModel
friend

Definition at line 21 of file qtreewidgetitemiterator.h.


The documentation for this class was generated from the following files: