PDA

View Full Version : How to set default icons of different file types?



merry
2nd June 2008, 09:49
Hi all

Can anybody know is there any class or function in Qt through which, It recognises the file type and sets icon of the file to the respective file type.

for eg. If there is a PNG file , then it set icon of the PNG file, in front of that file.

wysota
2nd June 2008, 09:59
You need to implement your own QFileIconProvider.

merry
2nd June 2008, 10:21
Thanx 4 the reply

Actually i am having a TreeWidget of Files and folders.

And these required every time the path of the file or folder whose Icon is to be used.

But I want to do like this that suppose If I add some files say

image.jpeg , Image1.gif, Image2.png ,Image4.bmp ,Music.mp3, Movie.avi then it should automatically show the Icon of the particular file.

Is it possible to do?

wysota
2nd June 2008, 15:24
Still you need to create an appropriate file icon provider and query it for icons. Of course you can also do that manually by checking filename suffixes and creating icons yourself.