通过控制台程序实现QList读写遍历方法

#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
    QString str = "Welcome to you ";
    qDebug() << str;
    QApplication a(argc, argv);
    QList<int> list;//创建一个空的列表list
    QMutableListIterator<int> i(list);//创建上述列表的读写迭代器
    for (int j = 0; j < 10; ++j)
            i.insert(j);
    for (i.toFront();i.hasNext();)
            qDebug() << i.next();
    for (i.toBack();i.hasPrevious();)
            qDebug() << i.previous();
    //MainWindow w;
    //w.show();

    return a.exec();
}

运行结果如下

"Welcome to you "
0
1
2
3
4
5
6
7
8
9
9
8
7
6
5
4
3
2
1
0

猜你喜欢

转载自blog.csdn.net/lonely_gfwolf/article/details/80369766
今日推荐