- 论坛徽章:
- 89
|
If you want to navigate through all the values stored in a QSet, you can use an iterator. QSet supports both Java-style iterators (QSetIterator and QMutableSetIterator) and STL-style iterators (QSet::iterator and QSet::const_iterator). Here's how to iterate over a QSet<QWidget *> using a Java-style iterator:
QSetIterator<QWidget *> i(set);
while (i.hasNext())
qDebug() << i.next();
Here's the same code, but using an STL-style iterator:
QSet<QWidget *>::const_iterator i = set.constBegin();
while (i != set.constEnd()) {
qDebug() << *i;
++i;
}
|
|