View Full Version : How to get system associated icon for any file

15th December 2009, 05:16

Please suggest me a function which will take a fileinfo as an argument and return the system associated icon for that file. QFileSystemModel has a function fileIcon which is returning icon of any folder correctly, but in case of a file it is always returning same icon for all types of file.

If currently Qt doesn't have any such function, please help me to write my own function. I know in Windows there is an API function SHGetFileInfo. I only need help for Linux and MacOS.

I found that QFileIconProvider did exactly what I wanted. But somehow it is working perfectly only on windows and KDE (I didn't check on MacOS), it is not working on Gnome (In Gnome it is returning default file icon for all types of file. But in case of folder it is working perfectly:mad:). Any idea how to get file icon in Gnome?