source: trunk/doc/html/appicon.html@ 203

Last change on this file since 203 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 9.7 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/appicon.doc:15 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>Setting the Application Icon</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Setting the Application Icon</h1>
33
34
35
36<p> The application icon, typically displayed in the top-left corner of an
37application's top-level windows, is set by calling the
38<a href="qwidget.html#setIcon">QWidget::setIcon</a>() method on top-level widgets.
39<p> In order to change the icon of the executable application file
40itself, as it is presented on the desktop (i.e. prior to application
41execution), it is necessary to employ another, platform-dependent
42technique.
43<p> <!-- toc -->
44<ul>
45<li><a href="#1"> Setting the Application Icon on Windows
46</a>
47<li><a href="#2"> Setting the Application Icon on Mac OS X
48</a>
49<li><a href="#3"> Setting the Application Icon on common Linux desktops
50</a>
51<ul>
52<li><a href="#3-1"> KDE
53</a>
54<li><a href="#3-2"> GNOME
55</a>
56</ul>
57</ul>
58<!-- endtoc -->
59
60<p> <h2> Setting the Application Icon on Windows
61</h2>
62<a name="1"></a><p> First, create an ICO format bitmap file that contains the icon image. This
63can be done with e.g. Microsoft Visual C++: Select "File|New...", then
64select the "File" tab in the dialog that appears, and choose "Icon". (Note
65that you do not need to load your application into Visual C++; here we are
66only using the icon editor).
67<p> Store the ICO file in your application's source code directory, for
68example, with the name, "myappico.ico". Then, create a text file
69called e.g. "myapp.rc" in which you put a single line of text:
70<pre>
71IDI_ICON1 ICON DISCARDABLE "myappico.ico"
72</pre>
73
74<p> Finally, assuming you are using <a href="qmake-manual.html">qmake</a>
75to generate your makefiles, add this line to your "myapp.pro" file:
76<p> <pre>
77RC_FILE = myapp.rc
78</pre>
79
80<p> Regenerate your makefile and your application. The .exe file will now be
81represented with your icon e.g. in Explorer.
82<p> If you do not use <a href="qmake-manual.html">qmake</a>, the necessary
83steps are: first, run the "rc" program on the .rc file, then link your
84application with the resulting .res file.
85<p> <h2> Setting the Application Icon on Mac OS X
86</h2>
87<a name="2"></a><p> The application icon, typically displayed in the application dock
88area, is set by calling <a href="qwidget.html#setIcon">QWidget::setIcon</a>() on a top-level widget. It
89is possible that the program could appear in the application dock area
90before the function call, in which case a default icon will appear
91during the bouncing animation.
92<p> To ensure that the correct icon appears, both when the application is
93being launched, and in the Finder, it is necessary to employ a
94platform-dependent technique.
95<p> Although many programs can create icon files (<tt>.icns</tt>), the recommended
96approach is to use the <em>Icon Composer</em> program supplied by Apple (in the
97Developer/Application folder). <em>Icon Composer</em> allows you to import several
98different sized icons (for use in different contexts) as well as the masks
99that go with them. Save the set of icons to a file in your project
100directory.
101<p> If you are using <a href="qmake-manual.html">qmake</a> to generate
102your make files, you only need to add a single line to your <tt>.pro</tt>
103project file. For example, if the name of your icon file is
104<tt>myapp.icns</tt>, and your project file is <tt>myapp.pro</tt>, add this line
105to <tt>myapp.pro</tt>:
106<pre>
107RC_FILE = myapp.icns
108</pre>
109
110This will ensure that <a href="qmake-manual.html">qmake</a> puts your
111icons in the proper place and creates an <tt>Info.plist</tt> entry for the
112icon.
113<p> If you do not use <a href="qmake-manual.html">qmake</a>, you must do
114the following manually:
115<ol type=1>
116<li> Create an Info.plist file for your application (using the
117PropertyListEditor, found in Developer/Applications).
118<li> Associate your .icns record with the CFBundleIconFile record in the
119Info.plist file (again, using the PropertyListEditor).
120<li> Copy both the icns and your Info.plist into your application bundle
121Resource directory.
122</ol>
123<p> <h2> Setting the Application Icon on common Linux desktops
124</h2>
125<a name="3"></a><p> In this section we briefly describe the issues involved in providing
126icons for applications for two common Linux desktop environments:
127<a href="http://www.kde.org/">KDE</a> and <a href="http://www.gnome.org/">GNOME</a>. The core technology used to describe application icons
128is the same for both desktops, and may also apply to others, but there
129are details which are specific to each. The main source of information
130on the standards used by these Linux desktops is <a href="http://www.freedesktop.org/">freedesktop.org</a>. For information
131on other Linux desktops please refer to the documentation for the
132desktops you are interested in.
133<p> Often, users do not use executable files directly, but instead launch
134applications by clicking icons on the desktop. These icons are
135representations of `desktop entry files' that contain a description of
136the application that includes information about its icon. Both desktop
137environments are able to retrieve the information in these files, and
138they use it to generate shortcuts to applications on the desktop, in
139the start menu, and on the panel.
140<p> More information about desktop entry files can be found in the
141<a href="http://www.freedesktop.org/Standards/desktop-entry-spec">Desktop Entry Specification</a>.
142<p> Although desktop entry files can usefully encapsulate the application's details,
143we still need to store the icons in the conventional location for each desktop
144environment. A number of locations for icons are given in the
145<a href="http://www.freedesktop.org/Standards/icon-theme-spec">Icon Theme Specification</a>.
146<p> Although the path used to locate icons depends on the desktop in use,
147and on its configuration, the directory structure beneath each of
148these should follow the same pattern: subdirectories are arranged by
149theme, icon size, and application type. Generally, application icons
150are added to the hicolor theme, so a square application icon 32 pixels
151in size would be stored in the <tt>hicolor/32x32/apps</tt> directory beneath
152the icon path.
153<p> <h3> KDE
154</h3>
155<a name="3-1"></a><p> Application icons can be installed for use by all users, or on a per-user basis.
156A user currently logged into their KDE desktop can discover these locations
157by using <a href="http://developer.kde.org/documentation/other/kde-config.html">kde-config</a>, for example,
158by typing the following in a terminal window:
159<p> <pre>
160kde-config --path icon
161</pre>
162
163<p> Typically, the list of colon-separated paths printed to stdout includes the
164user-specific icon path and the system-wide path. Beneath these
165directories, it should be possible to locate and install icons according
166to the conventions described in the
167<a href="http://www.freedesktop.org/Standards/icon-theme-spec">Icon Theme Specification</a>.
168<p> If you are developing exclusively for KDE, you may wish to take
169advantage of the <a href="http://developer.kde.org/documentation/other/makefile_am_howto.html">KDE build system</a> to configure your application. This ensures
170that your icons are installed in the appropriate locations for KDE.
171<p> The KDE developer website is <a href="http://developer.kde.org/">http://developer.kde.org/</a>.
172<p> <h3> GNOME
173</h3>
174<a name="3-2"></a><p> Application icons are stored within a standard system-wide directory containing
175architecture-independent files. This location can be determined by
176using gnome-config, for example by typing the following in a terminal
177window:
178<p> <pre>
179gnome-config --datadir
180</pre>
181
182<p> The path printed on stdout refers to a location that should contain a directory
183called <tt>pixmaps</tt>; the directory structure within the <tt>pixmaps</tt>
184directory is described in the <a href="http://www.freedesktop.org/Standards/icon-theme-spec">Icon Theme
185Specification</a>.
186<p> If you are developing exclusively for GNOME, you may wish to use
187the standard set of <a href="http://developer.gnome.org/tools/build.html">GNU Build Tools</a>,
188also described in the relevant section of
189the <a href="http://developer.gnome.org/doc/GGAD/ggad.html">GTK+/Gnome
190Application Development book</a>. This ensures that your icons are
191installed in the appropriate locations for GNOME.
192<p> The GNOME developer website is <a href="http://developer.gnome.org/">http://developer.gnome.org/</a>.
193<p>
194<!-- eof -->
195<p><address><hr><div align=center>
196<table width=100% cellspacing=0 border=0><tr>
197<td>Copyright &copy; 2007
198<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
199<td align=right><div align=right>Qt 3.3.8</div>
200</table></div></address></body>
201</html>
Note: See TracBrowser for help on using the repository browser.