Qt学习笔记,获取给定目录下面的所有文件名,及其path

Qt学习笔记,获取给定目录下面的所有文件名,及其path


    QDirModel listmodel;
    QString rootpath = "/home/powerlinux/";
    QDir dir(rootpath);
    //QStringList dirs = dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs);
    QStringList dirs = dir.entryList();
    for(int i=0; i<dirs.size(); i++){
       QModelIndex index = listmodel.index(rootpath+dirs.at(i));
        QString filepath = listmodel.filePath(index);
        qDebug() <<dirs.at(i)<< "'s index file path" << filepath;
    }


posted @ 2011-09-16 14:15  Podevor  阅读(711)  评论(0编辑  收藏  举报