• 7297阅读
  • 6回复

QT Creator中编译运行的程序无法显示系统图标 [复制链接]

上一主题 下一主题
离线郭木头
 
只看楼主 倒序阅读 楼主  发表于: 2011-03-11
如题所示,我刚开始学习QT,今天尝试对QT提供的例子中Analog Clock做了一点点修改,添了一个秒针。第一次运行成功,就发现窗口右上角的系统图标无法显示。新建对话框工程,在窗体属相烂设置了windowIcon,编译运行依然不能显示系统图标,而且新生成的exe文件也没有Icon
我弃MFC转QT就为做界面而来,这个问题有些诡异,令人百思不得其解。

恳请高手指教,先谢谢了。
离线郭木头
只看该作者 1楼 发表于: 2011-03-11
忘记说,我是在windows系统中出的问题,难道没有人遇到过同样的问题吗?

自己顶一下
离线wd007

只看该作者 2楼 发表于: 2011-03-12
你可以尝试回到最初,那个例子运行起来有图标显示吗。

再看看你更改了哪些地方,逐步的添加,每次都以能够显示图标为准。
欢迎访问我的博客,一起学习提高
http://blog.csdn.net/qter_wd007
离线jnblue

只看该作者 3楼 发表于: 2011-03-13
查阅QAssistant中的:Setting the Application Icon
Setting the Application Icon on Windows
First, 1create 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.)
2Store the ICO file in your application's source code directory, for example, with the name myappico.ico. Then,3 create a text file called, say, myapp.rc in which you put a single line of text:
IDI_ICON1               ICON    DISCARDABLE     "myappico.ico"
Finally, assuming you are using qmake to generate your makefiles,4 add this line to your myapp.pro file:
RC_FILE = myapp.rc
Regenerate your makefile and your application. The .exe file will now be represented with your icon in Explorer.
If you do not use qmake, the necessary steps are: first, run the rc program on the .rc file, then link your application with the resulting .res file.
离线郭木头
只看该作者 4楼 发表于: 2011-03-13
回 2楼(wd007) 的帖子
从一开始我没做任何改动,直接运行,试了好几个例子都无法显示系统图标。
感觉也许是系统的问题,打算过几天重装系统试试
离线郭木头
只看该作者 5楼 发表于: 2011-03-13
回 3楼(jnblue) 的帖子
我是在QT自己的IDE中做的,而且也试过类似的操作,添加ICO文件到资源,然后用setWindowIcon()设置,我还在界面编辑里对对话框属性设置了系统图标,皆无果。无奈……
离线jdwx

只看该作者 6楼 发表于: 2011-03-13
QT程序在Windows里显示图标:
1.准备一个图标,例如:main.ico(什么名字都行,但是要英文)
2.新建一个icon.rc的文件,里面输入:IDI_ICON1 ICON  "main.ico"
3.编辑.pro文件,添加一行:RC_FILE =  icon.rc
再编译就有图标了。
发帖时要说明:操作系统、Qt版本、编译器,这样能更快的得到回复。
快速回复
限100 字节
 
上一个 下一个