|
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 不知道怎么回事?求大神解答
|
|