• 14283阅读
  • 11回复

[提问]Qt5.0.2如何设置exe文件的图标 [复制链接]

上一主题 下一主题
离线luck__y
 

只看楼主 倒序阅读 楼主  发表于: 2013-12-28
关键词: 求助qt5
  用Qt5.0.2做了一个小程序,不知道该如何设置最后生成的exe文件的图标。网上查了下,发现都是说用rc文件,但是现在的版本变成qrc文件了,不知道该怎么做,求助下。
离线srl_mm

只看该作者 1楼 发表于: 2013-12-28
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.
离线_hwb

只看该作者 2楼 发表于: 2013-12-28
写一个脚本吧
离线friendbaby

只看该作者 3楼 发表于: 2013-12-28
如果是VS IDE  有该选项

Smiling is best language , can express everything , also can conceal everything.
离线ashe0817

只看该作者 4楼 发表于: 2013-12-28
在.pro文件里写
RC_ICONS = xxx.ico

xxx.ico 改成你的图标文件名
离线luck__y

只看该作者 5楼 发表于: 2013-12-29
回 1楼(srl_mm) 的帖子
这个我看了,不行吧,都没有rc文件,我这个版本只有qrc文件
离线luck__y

只看该作者 6楼 发表于: 2013-12-29
回 3楼(friendbaby) 的帖子
我的不是vs的
离线luck__y

只看该作者 7楼 发表于: 2013-12-29
回 2楼(_hwb) 的帖子
怎么写呀?能具体说一下吗
离线luck__y

只看该作者 8楼 发表于: 2013-12-29
引用第4楼ashe0817于2013-12-28 22:05发表的  :
在.pro文件里写
RC_ICONS = xxx.ico
xxx.ico 改成你的图标文件名

成功了,真是谢谢啦!!看来知道的东西还是太少了,得继续学习呀!
离线qxwq123t

只看该作者 9楼 发表于: 2014-01-04
谢谢,学习了。
离线srl_mm

只看该作者 10楼 发表于: 2014-02-05
回 luck__y 的帖子
luck__y:这个我看了,不行吧,都没有rc文件,我这个版本只有qrc文件 (2013-12-29 00:02)

我用Qt5.2.0可以,事实上在官方的帮助里搜Setting the Application Icon on Windows就是一楼我的回复
离线yangxiaoshuo

只看该作者 11楼 发表于: 2015-07-07
楼主,我也是用的5.0.2,新手,可以教教我如何创建qml应用程序吗
快速回复
限100 字节
 
上一个 下一个