码迷,mamicode.com
首页 > 其他好文 > 详细

Qt: 访问容器(三种方法,加上for循环就四种了)good

时间:2016-10-20 00:43:50      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:

#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 0;
}

http://www.cppblog.com/biao/archive/2008/03/21/45049.html

Qt: 访问容器(三种方法,加上for循环就四种了)good

标签:

原文地址:http://www.cnblogs.com/findumars/p/5979173.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!