[190] | 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"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { 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 Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main 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 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
|
---|
| 37 | application'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
|
---|
| 40 | itself, as it is presented on the desktop (i.e. prior to application
|
---|
| 41 | execution), it is necessary to employ another, platform-dependent
|
---|
| 42 | technique.
|
---|
| 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
|
---|
| 63 | can be done with e.g. Microsoft Visual C++: Select "File|New...", then
|
---|
| 64 | select the "File" tab in the dialog that appears, and choose "Icon". (Note
|
---|
| 65 | that you do not need to load your application into Visual C++; here we are
|
---|
| 66 | only using the icon editor).
|
---|
| 67 | <p> Store the ICO file in your application's source code directory, for
|
---|
| 68 | example, with the name, "myappico.ico". Then, create a text file
|
---|
| 69 | called e.g. "myapp.rc" in which you put a single line of text:
|
---|
| 70 | <pre>
|
---|
| 71 | IDI_ICON1 ICON DISCARDABLE "myappico.ico"
|
---|
| 72 | </pre>
|
---|
| 73 |
|
---|
| 74 | <p> Finally, assuming you are using <a href="qmake-manual.html">qmake</a>
|
---|
| 75 | to generate your makefiles, add this line to your "myapp.pro" file:
|
---|
| 76 | <p> <pre>
|
---|
| 77 | RC_FILE = myapp.rc
|
---|
| 78 | </pre>
|
---|
| 79 |
|
---|
| 80 | <p> Regenerate your makefile and your application. The .exe file will now be
|
---|
| 81 | represented with your icon e.g. in Explorer.
|
---|
| 82 | <p> If you do not use <a href="qmake-manual.html">qmake</a>, the necessary
|
---|
| 83 | steps are: first, run the "rc" program on the .rc file, then link your
|
---|
| 84 | application 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
|
---|
| 88 | area, is set by calling <a href="qwidget.html#setIcon">QWidget::setIcon</a>() on a top-level widget. It
|
---|
| 89 | is possible that the program could appear in the application dock area
|
---|
| 90 | before the function call, in which case a default icon will appear
|
---|
| 91 | during the bouncing animation.
|
---|
| 92 | <p> To ensure that the correct icon appears, both when the application is
|
---|
| 93 | being launched, and in the Finder, it is necessary to employ a
|
---|
| 94 | platform-dependent technique.
|
---|
| 95 | <p> Although many programs can create icon files (<tt>.icns</tt>), the recommended
|
---|
| 96 | approach is to use the <em>Icon Composer</em> program supplied by Apple (in the
|
---|
| 97 | Developer/Application folder). <em>Icon Composer</em> allows you to import several
|
---|
| 98 | different sized icons (for use in different contexts) as well as the masks
|
---|
| 99 | that go with them. Save the set of icons to a file in your project
|
---|
| 100 | directory.
|
---|
| 101 | <p> If you are using <a href="qmake-manual.html">qmake</a> to generate
|
---|
| 102 | your make files, you only need to add a single line to your <tt>.pro</tt>
|
---|
| 103 | project 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
|
---|
| 105 | to <tt>myapp.pro</tt>:
|
---|
| 106 | <pre>
|
---|
| 107 | RC_FILE = myapp.icns
|
---|
| 108 | </pre>
|
---|
| 109 |
|
---|
| 110 | This will ensure that <a href="qmake-manual.html">qmake</a> puts your
|
---|
| 111 | icons in the proper place and creates an <tt>Info.plist</tt> entry for the
|
---|
| 112 | icon.
|
---|
| 113 | <p> If you do not use <a href="qmake-manual.html">qmake</a>, you must do
|
---|
| 114 | the following manually:
|
---|
| 115 | <ol type=1>
|
---|
| 116 | <li> Create an Info.plist file for your application (using the
|
---|
| 117 | PropertyListEditor, found in Developer/Applications).
|
---|
| 118 | <li> Associate your .icns record with the CFBundleIconFile record in the
|
---|
| 119 | Info.plist file (again, using the PropertyListEditor).
|
---|
| 120 | <li> Copy both the icns and your Info.plist into your application bundle
|
---|
| 121 | Resource 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
|
---|
| 126 | icons 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
|
---|
| 128 | is the same for both desktops, and may also apply to others, but there
|
---|
| 129 | are details which are specific to each. The main source of information
|
---|
| 130 | on the standards used by these Linux desktops is <a href="http://www.freedesktop.org/">freedesktop.org</a>. For information
|
---|
| 131 | on other Linux desktops please refer to the documentation for the
|
---|
| 132 | desktops you are interested in.
|
---|
| 133 | <p> Often, users do not use executable files directly, but instead launch
|
---|
| 134 | applications by clicking icons on the desktop. These icons are
|
---|
| 135 | representations of `desktop entry files' that contain a description of
|
---|
| 136 | the application that includes information about its icon. Both desktop
|
---|
| 137 | environments are able to retrieve the information in these files, and
|
---|
| 138 | they use it to generate shortcuts to applications on the desktop, in
|
---|
| 139 | the 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,
|
---|
| 143 | we still need to store the icons in the conventional location for each desktop
|
---|
| 144 | environment. 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,
|
---|
| 147 | and on its configuration, the directory structure beneath each of
|
---|
| 148 | these should follow the same pattern: subdirectories are arranged by
|
---|
| 149 | theme, icon size, and application type. Generally, application icons
|
---|
| 150 | are added to the hicolor theme, so a square application icon 32 pixels
|
---|
| 151 | in size would be stored in the <tt>hicolor/32x32/apps</tt> directory beneath
|
---|
| 152 | the 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.
|
---|
| 156 | A user currently logged into their KDE desktop can discover these locations
|
---|
| 157 | by using <a href="http://developer.kde.org/documentation/other/kde-config.html">kde-config</a>, for example,
|
---|
| 158 | by typing the following in a terminal window:
|
---|
| 159 | <p> <pre>
|
---|
| 160 | kde-config --path icon
|
---|
| 161 | </pre>
|
---|
| 162 |
|
---|
| 163 | <p> Typically, the list of colon-separated paths printed to stdout includes the
|
---|
| 164 | user-specific icon path and the system-wide path. Beneath these
|
---|
| 165 | directories, it should be possible to locate and install icons according
|
---|
| 166 | to 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
|
---|
| 169 | advantage of the <a href="http://developer.kde.org/documentation/other/makefile_am_howto.html">KDE build system</a> to configure your application. This ensures
|
---|
| 170 | that 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
|
---|
| 175 | architecture-independent files. This location can be determined by
|
---|
| 176 | using gnome-config, for example by typing the following in a terminal
|
---|
| 177 | window:
|
---|
| 178 | <p> <pre>
|
---|
| 179 | gnome-config --datadir
|
---|
| 180 | </pre>
|
---|
| 181 |
|
---|
| 182 | <p> The path printed on stdout refers to a location that should contain a directory
|
---|
| 183 | called <tt>pixmaps</tt>; the directory structure within the <tt>pixmaps</tt>
|
---|
| 184 | directory is described in the <a href="http://www.freedesktop.org/Standards/icon-theme-spec">Icon Theme
|
---|
| 185 | Specification</a>.
|
---|
| 186 | <p> If you are developing exclusively for GNOME, you may wish to use
|
---|
| 187 | the standard set of <a href="http://developer.gnome.org/tools/build.html">GNU Build Tools</a>,
|
---|
| 188 | also described in the relevant section of
|
---|
| 189 | the <a href="http://developer.gnome.org/doc/GGAD/ggad.html">GTK+/Gnome
|
---|
| 190 | Application Development book</a>. This ensures that your icons are
|
---|
| 191 | installed 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 © 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>
|
---|