[Qt-interest] How to get an icon associated with a certain filetype using Qt?

Nikos Chantziaras realnc at arcor.de
Fri Mar 26 18:12:49 CET 2010


On 03/26/2010 10:34 AM, Oliver.Knoll at comit.ch wrote:
> Nikos Chantziaras wrote on Wednesday, March 24, 2010 7:10 PM:
>
>>> ...
>>> And does it really have to be the icon of the application which can
>>> deal with that MIME type? Or would "generic" icons be sufficient?
>>
>> That doesn't work that way.  There's only one icon used, no matter
>> how many applications can open the file.  That's true on all
>
> I think you missed my point: I wasn't exactly talking about *multiple* icons. I was suggesting to use a "generic" icon instead of the "real" icon from the *one* application that is associated with that file (identified by its MIME or extension or magic number or...).
>
> The reason I was suggesting this is that there might be *multiple* applications which would be able to deal with say MIME image/jpeg, but only *one* application which is actually (directly) associated with with (by the file extension, for example). So given only the MIME it is actually impossible to determine that *one* application which is associated with a given file (when you double-click on it).

And what generic icon are you going to pick?  There's isn't even a 
generic one available :)  And if you include generic icons in your app, 
what are you going to include?  There are thousands of MIME types.  And, 
your app will not behave and look "native", like apps targeted 
specifically for that plattform, apps that would show the correct icon 
that would be used by the OS itself for a given MIME type.

The best that can be done is query the OS using the native API.



More information about the Qt-interest-old mailing list