Qt主窗口未加载其图标

时间:2013-01-10 16:51:44

标签: qt icons qt-designer

我正在使用 Qt 4.8.4 ,我使用 Qt Designer 创建了 QMainWindow ,因此我的.ui文件会生成相应的ui_ .... h文件。我有相应的.qrc,里面有正确的图标,当我使用Qt Designer预览窗口时,我可以看到它。最后,在加载应用程序时,窗口没有任何图标,只是默认的Windows应用程序图标。

我正在使用Visual Studio 2010来编译项目。因此,我没有使用任何'.pro'文件。以下是编译Qt资源文件的.vcxproj的代码:

<CustomBuild Include="dlgConnect.qrc">
  <FileType>Document</FileType>
  <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(FullPath);%(AdditionalInputs)</AdditionalInputs>
  <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Rcc%27ing %(Identity)...</Message>
  <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs)</Outputs>
  <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"..\..\..\..\Software\QtSDK\Desktop\Qt\4.8.4\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp</Command>
  <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(FullPath);%(AdditionalInputs)</AdditionalInputs>
  <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Rcc%27ing %(Identity)...</Message>
  <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs)</Outputs>
  <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"..\..\..\..\Software\QtSDK\Desktop\Qt\4.8.4\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp</Command>
</CustomBuild>

这似乎是正确的,但我没有成功的结果。

有没有人经历过同样的事情?

干杯,

1 个答案:

答案 0 :(得分:3)

您需要在 .pro 文件

中使用此功能
RC_FILE += Icon.rc

您需要在 Icon.rc 文件

中使用此功能
IDI_ICON1   ICON   DISCARDABLE   "./MyIcon.ico"

您需要 MyIcon.ico 图标文件。

相关问题