The QTreeWidgetItemIterator class provides a way to iterate over the items in a QTreeWidget 实例。 更多...
头: | #include <QTreeWidgetItemIterator> |
qmake: | QT += widgets |
enum | IteratorFlag { All, Hidden, NotHidden, Selected, ..., UserFlag } |
flags | IteratorFlags |
QTreeWidgetItemIterator (const QTreeWidgetItemIterator & it ) | |
QTreeWidgetItemIterator (QTreeWidget * widget , QTreeWidgetItemIterator::IteratorFlags flags = All) | |
QTreeWidgetItemIterator (QTreeWidgetItem * item , QTreeWidgetItemIterator::IteratorFlags flags = All) | |
~QTreeWidgetItemIterator () | |
QTreeWidgetItem * | operator* () const |
QTreeWidgetItemIterator & | operator++ () |
const QTreeWidgetItemIterator | operator++ ( int ) |
QTreeWidgetItemIterator & | operator+= (int n ) |
QTreeWidgetItemIterator & | operator-- () |
const QTreeWidgetItemIterator | operator-- ( int ) |
QTreeWidgetItemIterator & | operator-= (int n ) |
QTreeWidgetItemIterator & | operator= (const QTreeWidgetItemIterator & it ) |
The QTreeWidgetItemIterator class provides a way to iterate over the items in a QTreeWidget 实例。
迭代器将按预定次序的遍历顺序走查项,从而拜访父级节点 before 它继续到子级节点。
例如,以下代码范例中的每一树项,对照用户指定的搜索字符串校验首列文本:
QTreeWidgetItemIterator it(treeWidget); while (*it) { if ((*it)->text(0) == itemText) (*it)->setSelected(true); ++it; }
过滤出某些类型的节点也是可能的,通过传递一些 flags to the constructor of QTreeWidgetItemIterator .
另请参阅 QTreeWidget , 模型/视图编程 ,和 QTreeWidgetItem .
这些标志可以传递给 QTreeWidgetItemIterator 构造函数 (OR 在一起若使用一个以上),以便迭代器将仅迭代匹配给定标志的项。
常量 | 值 |
---|---|
QTreeWidgetItemIterator::All
|
0x00000000
|
QTreeWidgetItemIterator::Hidden
|
0x00000001
|
QTreeWidgetItemIterator::NotHidden
|
0x00000002
|
QTreeWidgetItemIterator::Selected
|
0x00000004
|
QTreeWidgetItemIterator::Unselected
|
0x00000008
|
QTreeWidgetItemIterator::Selectable
|
0x00000010
|
QTreeWidgetItemIterator::NotSelectable
|
0x00000020
|
QTreeWidgetItemIterator::DragEnabled
|
0x00000040
|
QTreeWidgetItemIterator::DragDisabled
|
0x00000080
|
QTreeWidgetItemIterator::DropEnabled
|
0x00000100
|
QTreeWidgetItemIterator::DropDisabled
|
0x00000200
|
QTreeWidgetItemIterator::HasChildren
|
0x00000400
|
QTreeWidgetItemIterator::NoChildren
|
0x00000800
|
QTreeWidgetItemIterator::Checked
|
0x00001000
|
QTreeWidgetItemIterator::NotChecked
|
0x00002000
|
QTreeWidgetItemIterator::Enabled
|
0x00004000
|
QTreeWidgetItemIterator::Disabled
|
0x00008000
|
QTreeWidgetItemIterator::Editable
|
0x00010000
|
QTreeWidgetItemIterator::NotEditable
|
0x00020000
|
QTreeWidgetItemIterator::UserFlag
|
0x01000000
|
IteratorFlags 类型是 typedef 对于 QFlags <IteratorFlag>。它存储 IteratorFlag 值的 OR 组合。
构造迭代器为相同 QTreeWidget as it 。当前迭代器项被设为指向当前项在 it .
构造迭代器为给定 widget 使用指定 flags 以确定在迭代期间找到哪些项。迭代器被设为指向 Widget 包含的第一顶层项,或下一匹配项若顶层项不匹配标志。
另请参阅 QTreeWidgetItemIterator::IteratorFlag .
构造迭代器为给定 item 使用指定 flags 以确定在迭代期间找到哪些项。迭代器被设为指向 item ,或下一匹配项若 item 不匹配标志。
另请参阅 QTreeWidgetItemIterator::IteratorFlag .
销毁迭代器。
解引用运算符。返回指向当前项的指针。
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 0 if the current item is the last matching item.
后缀 ++ 运算符 (it++) 把迭代器推进到下一匹配项,并返回指向先前当前项迭代器。
使迭代器前进 n 匹配项 (若 n 为负,迭代器后退)。
If the current item is beyond the last item, the current item pointer is set to 0. Returns the resulting iterator.
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 0 if the current item is the first matching item.
后缀 -- 运算符 (it--) 使之前的匹配当前项,并返回指向先前当前项迭代器。
使迭代器后退 n 匹配项 (若 n 为负,迭代器前进)。
If the current item is ahead of the last item, the current item pointer is set to 0. Returns the resulting iterator.
赋值。制作副本为 it 并返回其迭代器的引用。