3

How to get a filepath via QFileSystemModel? Selecting via selection model returns just file name, or drive name.

Note, that just file name isn't enough. Whole filepath is needed.

smallB
  • 16,662
  • 33
  • 107
  • 151

2 Answers2

7

On qt website: http://doc.qt.io/qt-5/qfilesystemmodel.html

QString QFileSystemModel::filePath ( const QModelIndex & index ) const Returns the path of the item stored in the model under the index given.

I dont know if this answers your question, else you can give us some code about what you tried / are trying to reach.

Bowdzone
  • 3,827
  • 11
  • 39
  • 52
Stefan Koenen
  • 2,289
  • 2
  • 20
  • 32
  • I think it is not working for PySide6. I get this error: "{TypeError}descriptor 'filePath' for 'PySide6.QtWidgets.QFileSystemModel' objects doesn't apply to a 'PySide6.QtCore.QModelIndex' object" – E.G. Cortes Jun 05 '22 at 14:36
0

You can do this by using something like this QFileSystemModel::filePath(index).

v01d
  • 1,457
  • 1
  • 11
  • 22