找回密码
 立即注册
收起左侧

QFileSystemModel学习过程遇到的问题

0
回复
5731
查看
[复制链接]
累计签到:17 天
连续签到:2 天
来源: 2017-10-16 22:21:50 显示全部楼层 |阅读模式
1Qter豆
本帖最后由 yanweitom 于 2017-10-16 22:22 编辑

Qt学习之路系列教程目录下的第45篇讲到:
        QFileSystemModel *model = new QFileSystemModel;
       QModelIndex parentIndex = model->index(QDir::currentPath());  
        int rowii = model->rowCount(parentIndex);   
        qDebug()<<rowii;
    for (int row = 0; row < rowii; ++row) {      
         QModelIndex index = model->index(row, 0, parentIndex);      
        QString text = model->data(index, Qt::DisplayRole).toString();   
        qDebug()<<text;      
  // 使用 text 数据  
   }

按照教程,text应该存放当前目录下的文件夹和文件,可是运行程序后输入text为空,rowCount返回值也为1 不知道怎么回事?求大神解答

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

公告
可以关注我们的微信公众号yafeilinux_friends获取最新动态,或者加入QQ会员群进行交流:190741849、186601429(已满) 我知道了