怎么获得qtableview的行数

我使用qtableview加载QFileSystemModel后通过tableView->model()->rowCount()想要获得某个文件夹的文件数,得到的值却是我的电脑的磁盘数量。
怎样才能得到正确的答案呢?非常感谢。

tableview 怕是无法展开文件系统吧;一般使用的数QTreeView;

QFileSystemModel *model = new QFileSystemModel;
    model->setRootPath(QDir::currentPath());
    ui->treeView->setModel(model);

void Widget::on_treeView_clicked(const QModelIndex &index)
{
    QFileSystemModel * mode = qobject_cast<QFileSystemModel*>(ui->treeView->model());
    if(mode->isDir(index)){
        QString path = mode->filePath(index);
        qDebug()<<"路径:"<<path;
        QDir dir(path);
        auto ret = dir.entryList();
        qDebug()<<ret.size();
    }
}


直接调用rowCount()没有参数吗,那不就是返回root的rowCount,如果要某个文件夹下面的应该把对应的index传进去吧