现在的位置: 首页 > 综合 > 正文

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

2014年09月15日 ⁄ 综合 ⁄ 共 375字 ⁄ 字号 评论关闭

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

抱歉!评论已关闭.