Qt5.7设置应用程序图标-基于Windows

来源:互联网 发布:有赞源码下载 编辑:程序博客网 时间:2024/05/20 21:18
Setting the Application Icon on Windows

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.)

Store the ICO file in your application's source code directory, for example, with the name myappico.ico.


Then, assuming you are using qmake to generate your makefiles, you only need to add a single line to your .pro project file:
  RC_ICONS = myappico.ico


Finally, regenerate your makefile and your application. The .exe file will now be represented by your icon in Explorer.
However, if you already have an .rc file, for example, with the name myapp.rc, which you want to reuse, the following two steps will be required. First, put a single line of text to the myapp.rc file:


  IDI_ICON1               ICON    DISCARDABLE     "myappico.ico"


Then, add this line to your myapp.pro file:


  RC_FILE = myapp.rc


If you do not use qmake, the necessary steps are: first, create an .rc file and run the rc or windres program on the .rc file, then link your application with the resulting .res file. 

0 0