Reputation: 8277
I have a QListView
that adds a newly added file to a folder using QFileSystemWatcher
, however I also want QListView
to show the icon for that filetype just as QFileSystemModel
would add. I do not want to add any custom icon only the icon that Operating system has registered for the specific to file type.
Upvotes: 1
Views: 2218
Reputation: 8277
I just figured out how to achieve this using the code below:
fileInfo = QtCore.QFileInfo(path)
iconProvider = QtGui.QFileIconProvider()
icon = iconProvider.icon(fileInfo)
Upvotes: 1