QListIterator and QStringList
#include <QStringList>
#include <QDebug>
int main() {
QString winter = "A, B, C";
QString spring = "D, E, F";
QString summer = "G, H, I";
QString fall = "X, Y, Z";
QStringList list;
list << winter;
list += spring;
list.append(summer);
list << fall;
QString allmonths = list.join(", ");
QStringList list2 = allmonths.split(", ");
Q_ASSERT(list2.size() == 12);
for (QStringList::iterator it = list.begin();
it != list.end(); ++it) {
QString current = *it;
qDebug() << "[[" << current << "]]";
}
QListIterator<QString> itr (list2);
while (itr.hasNext()) {
QString current = itr.next();
qDebug() << "{" << current << "}";
}
return 0;
}
Related examples in the same category