KIconLoader

Aaron J. Seigo aseigo at kde.org
Thu Jan 7 21:39:15 GMT 2010


On January 7, 2010, Lynn Hazan wrote:
> If anyone can help me on the following topic I will really appreciate as I
> have been fighting with for days.
> 
> I just want to specify my own icons and cursors. I did it without any
> problem using KDE3 but with KDE4 I can not manage to do it. The only thing
> I can get is the unknow icon (
> /usr/lib/kde4/share/icons/oxygen/16x16/mimetypes/unknown.png).
> I am sure it is pretty easy to do when you know how.
> 
> Here is what I did :
> 
> * create an icons directory in my source directory

put a CMakeLists.txt file in this directory with just "kde4_install_icons( 
${ICON_INSTALL_DIR}   )" in it and then put add_subdirectory(icons) in the top 
level CMakeLists.txt

> * add an icon (zoom_tool.png) in this directory

should be something like ox32-action-zoom_tool.png which means "put this in 
the actions directory, it's an oxygen icon, size of 32 pixels". adjust as 
appropriate :)

> * try to upload the icon in my code:
> KIconLoader *loader = KIconLoader::global();
> KAction* selectAction = new KAction(this);
>   selectAction->setIcon(KIcon(loader->loadIcon("zoom_tool",
> KIconLoader::NoGroup)));

you should be able to just do KIcon("zoom_tool")

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Qt Development Frameworks




More information about the kde-core-devel mailing list