![](/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.