#include <iostream>
#include <QString>
#include <QList>
#include <QListIterator> int main(int argc, char *argv[]) {
QList<QString> list;
list << "One" << "Two" << "Three"; foreach(QString s, list) {
std::cout << s.toStdString() << std::endl;
} QListIterator<QString> iter(list);
while (iter.hasNext()) {
std::cout << iter.next().toStdString() << std::endl;
} QList<QString>::Iterator stlIter; // QList<QString>::iterator stlIter; // Ok
for (stlIter = list.begin(); stlIter != list.end(); ++stlIter) {
std::cout << stlIter->toStdString() << std::endl;
} return ;
}
原文 : http://www.cppblog.com/biao/archive/2008/03/21/45049.html