CopperSpice API  1.8.1
Application Icon

The application icon is typically displayed in the top-left corner of an application's top-level windows. It is set by calling the QWidget::setWindowIcon() method on top-level widgets. In order to change the icon embedded in the executable application you must use platform specific techniques.

Setting the Application Icon on Windows

Create an ICO format bitmap file that contains the icon image. Save the ICO file in your application source code directory.

In this example the ICO file name is called myappico.ico. Then create a text file called, say, myapp.rc in which you put a single line of text:


The necessary steps are:

1) run the rc program on the .rc file 2) link your application with the resulting .res file

Setting the Application Icon on Mac OS X

The application icon, typically displayed in the application dock area, is set by calling QWidget::setWindowIcon() on a top-level widget. It is possible that the program could appear in the application dock area before the function call, in which case a default icon will appear during the bouncing animation.

To ensure that the correct icon appears, both when the application is being launched, and in the Finder, it is necessary to employ a platform-dependent technique.

Although many programs can create icon files (.icns), the recommended approach is to use the Icon Composer program supplied by Apple (in the Developer/Application folder). Icon Composer allows you to import several different sized icons (for use in different contexts) as well as the masks that go with them. Save the set of icons to a file in your project directory.

The necessary steps are:

  1. Create an Info.plist file for your application (using the PropertyListEditor, found in Developer/Applications).
  2. Associate your .icns record with the CFBundleIconFile record in the Info.plist file (again, using the PropertyListEditor).
  3. Copy the Info.plist file into your application bundle's Contents directory.
  4. Copy the .icns file into your application bundle's Contents/Resources directory.

Setting the Application Icon on Common Linux Desktops

In this section we briefly describe the issues involved in providing icons for applications for two common Linux desktop environments: KDE and GNOME.

The core technology used to describe application icons is the same for both desktops and may also apply to others. The main source of information on the standards used by these Linux desktops is For information on other Linux desktops please refer to the documentation for the desktops you are interested in.

Often, users do not use executable files directly, but instead launch applications by clicking icons on the desktop. These icons are representations of "desktop entry files" that contain a description of the application that includes information about its icon. Both desktop environments are able to retrieve the information in these files, and they use it to generate shortcuts to applications on the desktop, in the start menu, and on the panel.

More information about desktop entry files can be found in the Desktop Entry Specification.

Although desktop entry files can usefully encapsulate the application's details, we still need to store the icons in the conventional location for each desktop environment. A number of locations for icons are given in the Icon Theme Specification.

Although the path used to locate icons depends on the desktop in use, and on its configuration, the directory structure beneath each of these should follow the same pattern: subdirectories are arranged by theme, icon size, and application type. Generally, application icons are added to the hicolor theme, so a square application icon 32 pixels in size would be stored in the hicolor/32x32/apps directory beneath the icon path.

K Desktop Environment (KDE)

Application icons can be installed for use by all users, or on a per-user basis. A user currently logged into their KDE desktop can discover these locations by using "kde-config".

kde-config --path icon

Typically the list of colon-separated paths printed to stdout includes the user-specific icon path and the system-wide path. Beneath these directories, it should be possible to locate and install icons according to the conventions described in the Icon Theme Specification.


Application icons are stored within a standard system-wide directory containing architecture-independent files. This location can be determined by using gnome-config, for example by typing the following in a terminal window:

gnome-config --datadir

The path printed on stdout refers to a location that should contain a directory called pixmaps; the directory structure within the pixmaps directory is described in the Icon Theme Specification.

If you are developing exclusively for GNOME refer to the standard set of "GNU Build Tools" described in the "GTK+/Gnome Application Development book".