![](/img/trans.png)
[英]How to access QStandardItemModel and it's data using a QModelIndex?
[英]How to get path from a QStandardItemModel using a QModelIndex?
我想使用QModelIndex从QStandardItemModel获取目录的路径。 可能吗? 我看到可以使用QString QFileSystemModel::filePath ( const QModelIndex & index ) const
。 但是当我运行以下代码时,它崩溃了:
QString _path = qobject_cast<QFileSystemModel*>(model)->filePath(modelIndex);
如果我创建QFileSystemModel
的实例并传递QModelIndex
:
QFileSystemModel* fileSystem = new QFileSystemModel();
QString myPath = fileSystem->filePath(modelIndex);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.