Ciasto piekarz
Ciasto piekarz

Reputation: 8277

How to get an icon associated with a certain file type using PyQt/PySide?

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

Answers (1)

Ciasto piekarz
Ciasto piekarz

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

Related Questions