-
Notifications
You must be signed in to change notification settings - Fork 752
Setting the Application Icon
The application icon, which typically displayed in the top-left corner of an application, can be set by calling the SetIcon()
method in the main window of your app. However, in order to change the icon of the executable file itself (i.e., prior to application execution), it is necessary to employ another, platform-dependent technique.
-
Make sure you have an ICO format bitmap file that contains the icon image for your app.
-
Store the ICO file in your project's root directory, for example, with the name
myicon.ico
. -
Create a file called
icon.rc
with the following content in your root project directory :IDI_ICON1 ICON DISCARDABLE "myicon.ico"
-
Open terminal inside your project directory, then run
windres
like this :path/to/windres icon.rc -o icon_windows.syso
In Windows system,
windres
usually can be found inside the same folder asrcc
, for example inQt5.8.0/5.8/mingw53_32/bin/windres.exe
. In Linux, you have to installmingw-w64
first using your package manager. Once installled, you can runwindres
either by callingi686-w64-mingw32-windres
(if you deploying for Windows 32-bit) orx86_64-w64-mingw32-windres
(if you deploying for Windows 64-bit).At this point, your project directory should look like this :
project_name ├── icon.rc ├── icon_windows.syso ├── myicon.ico └── project.go
-
Deploy your app like usual, the
*.syso
file should be automatically detected and be added to your binary.
-
Make sure you have an icon files (
.icns
) that contains the icon image for your app. Although many programs can create icns files, the recommended approach is to use theiconutil
program supplied by Apple.iconutil
is a command-line tool that converts iconset folders to deployment-ready, high-resolution icns files. Using this tool also compresses the resulting icns file, so there is no need for you to perform additional compression. -
Copy your icns file to
project-directory/darwin/Contents/Resources
, for example, with the nameproject_name.icns
. -
Open or create
Info.plist
file which located inproject-directory/darwin/Contents/Info.plist
. -
Associate your
project_name.icns
record with theCFBundleIconFile
record in theInfo.plist
. At this point, your project directory should look like this :project_name ├── darwin │ └── Contents │ ├── Info.plist │ └── Resources │ └── project_name.icns └── project.go
-
Deploy your app like usual.
Executable files on Linux do not have icons embedded in itself. Instead, the icons is displayed on Desktop Entry files that contain a description of the application that includes information about its icon. For more details, you can check the Arch wiki.
Just like other Android project, you can set the application icon by modifying AndroidManifest.xml
file. Using this binding, the manifest file will be located under android
or android-emulator
folder at the root of your project :
project_name
├── android
│ ├── AndroidManifest.xml
│ ├── alias.txt
│ ├── build.gradle
│ ├── gradle
│ │ └── wrapper
│ │ └── gradle-wrapper.properties
│ ├── icon.png
│ ├── password.txt
│ ├── project_name.keystore
│ └── res
│ ├── drawable-hdpi
│ │ └── icon.png
│ ├── drawable-ldpi
│ │ └── icon.png
│ └── drawable-mdpi
│ └── icon.png
└── project.go
To set the icon, you can use the *.desktop
and *.spec
files, which located inside sailfish
or sailfish-emulator
folder at the root of your project, as a template to build upon :
project_name
├── project.go
└── sailfish
├── harbour-project_name.png
├── project_name.desktop
└── project_name.spec