qt的版本,是4還是5。妳可以查看assistant中的
Setting the Application Icon
裏面有詳細的設置應用程序圖標的說明。
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_ICON1ICONDISCARDABLE?"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.
首先,妳需要創建壹個包含圖標的ICO格式的位圖文件。VC下:選擇 文件|新建,選擇對話框中的文件標簽,再選擇ICON。
將ICO文件保存在程序源代碼的目錄下,比如命名為myappico.ico.
假設妳使用qmake來生成makefiles文件,妳只需要在.pro文件中添加壹行:
RC_ICONS = myappico.ico
最後,重新生成makefile和應用程序。然後,exe文件就會顯示妳設置的圖標了。
不過,如果妳已經有了壹個.rc文件的話,比如myapp.rc,添加下面的兩行。首先,在myapp.rc中添加壹行:
IDI_ICON1 ? ICON DISCARDABLE "myappico.ico"
然後在.pro中添加壹行:
RC_FILE = myapp.rc
如果妳用的不是qmake,必要的步驟有:首先,創建壹個.rc文件,然後運行rc或者windres程序,最後將妳的應用程序和.res文件鏈接在壹塊就行了。