<tdalign="right"valign="center"><imgsrc="logo32.png"align="right"width="64"height="32"border="0"></td></tr></table><h1align=center>Setting the Application Icon</h1>
<p> The application icon, typically displayed in the top-left corner of an
application's top-level windows, is set by calling the
<ahref="qwidget.html#setIcon">QWidget::setIcon</a>() method on top-level widgets.
<p> In order to change the icon of the executable application file
itself, as it is presented on the desktop (i.e. prior to application
execution), it is necessary to employ another, platform-dependent
technique.
<p><!-- toc -->
<ul>
<li><ahref="#1"> Setting the Application Icon on Windows
</a>
<li><ahref="#2"> Setting the Application Icon on Mac OS X
</a>
<li><ahref="#3"> Setting the Application Icon on common Linux desktops
</a>
<ul>
<li><ahref="#3-1"> KDE
</a>
<li><ahref="#3-2"> GNOME
</a>
</ul>
</ul>
<!-- endtoc -->
<p><h2> Setting the Application Icon on Windows
</h2>
<aname="1"></a><p> First, create an ICO format bitmap file that contains the icon image. This
can be done with e.g. Microsoft Visual C++: Select "File|New...", then
select the "File" tab in the dialog that appears, and choose "Icon". (Note
that you do not need to load your application into Visual C++; here we are
only using the icon editor).
<p> Store the ICO file in your application's source code directory, for
example, with the name, "myappico.ico". Then, create a text file
called e.g. "myapp.rc" in which you put a single line of text:
<pre>
IDI_ICON1 ICON DISCARDABLE "myappico.ico"
</pre>
<p> Finally, assuming you are using <ahref="qmake-manual.html">qmake</a>
to generate your makefiles, add this line to your "myapp.pro" file:
<p><pre>
RC_FILE = myapp.rc
</pre>
<p> Regenerate your makefile and your application. The .exe file will now be
represented with your icon e.g. in Explorer.
<p> If you do not use <ahref="qmake-manual.html">qmake</a>, the necessary
steps are: first, run the "rc" program on the .rc file, then link your
application with the resulting .res file.
<p><h2> Setting the Application Icon on Mac OS X
</h2>
<aname="2"></a><p> The application icon, typically displayed in the application dock
area, is set by calling <ahref="qwidget.html#setIcon">QWidget::setIcon</a>() 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.
<p> 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.
<p> Although many programs can create icon files (<tt>.icns</tt>), the recommended
approach is to use the <em>Icon Composer</em> program supplied by Apple (in the
Developer/Application folder). <em>Icon Composer</em> 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.
<p> If you are using <ahref="qmake-manual.html">qmake</a> to generate
your make files, you only need to add a single line to your <tt>.pro</tt>
project file. For example, if the name of your icon file is
<tt>myapp.icns</tt>, and your project file is <tt>myapp.pro</tt>, add this line
to <tt>myapp.pro</tt>:
<pre>
RC_FILE = myapp.icns
</pre>
This will ensure that <ahref="qmake-manual.html">qmake</a> puts your
icons in the proper place and creates an <tt>Info.plist</tt> entry for the
icon.
<p> If you do not use <ahref="qmake-manual.html">qmake</a>, you must do
the following manually:
<oltype=1>
<li> Create an Info.plist file for your application (using the
PropertyListEditor, found in Developer/Applications).
<li> Associate your .icns record with the CFBundleIconFile record in the
Info.plist file (again, using the PropertyListEditor).
<li> Copy both the icns and your Info.plist into your application bundle
Resource directory.
</ol>
<p><h2> Setting the Application Icon on common Linux desktops
</h2>
<aname="3"></a><p> In this section we briefly describe the issues involved in providing
icons for applications for two common Linux desktop environments:
<ahref="http://www.kde.org/">KDE</a> and <ahref="http://www.gnome.org/">GNOME</a>. The core technology used to describe application icons
is the same for both desktops, and may also apply to others, but there
are details which are specific to each. The main source of information
on the standards used by these Linux desktops is <ahref="http://www.freedesktop.org/">freedesktop.org</a>. For information
on other Linux desktops please refer to the documentation for the
desktops you are interested in.
<p> 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.
<p> More information about desktop entry files can be found in the
<p> If you are developing exclusively for KDE, you may wish to take
advantage of the <ahref="http://developer.kde.org/documentation/other/makefile_am_howto.html">KDE build system</a> to configure your application. This ensures
that your icons are installed in the appropriate locations for KDE.
<p> The KDE developer website is <ahref="http://developer.kde.org/">http://developer.kde.org/</a>.
<p><h3> GNOME
</h3>
<aname="3-2"></a><p> 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:
<p><pre>
gnome-config --datadir
</pre>
<p> The path printed on stdout refers to a location that should contain a directory
called <tt>pixmaps</tt>; the directory structure within the <tt>pixmaps</tt>
directory is described in the <ahref="http://www.freedesktop.org/Standards/icon-theme-spec">Icon Theme
Specification</a>.
<p> If you are developing exclusively for GNOME, you may wish to use
the standard set of <ahref="http://developer.gnome.org/tools/build.html">GNU Build Tools</a>,
also described in the relevant section of
the <ahref="http://developer.gnome.org/doc/GGAD/ggad.html">GTK+/Gnome
Application Development book</a>. This ensures that your icons are
installed in the appropriate locations for GNOME.
<p> The GNOME developer website is <ahref="http://developer.gnome.org/">http://developer.gnome.org/</a>.