尽管在资源中有效(并在其他地方使用),但 WindowIcon 未显示

发布于 2024-10-01 15:34:51 字数 461 浏览 0 评论 0原文

在我的上一个问题中(Qt/C++:图标未显示当程序运行时)我询问如何让图标显示在工具栏上,并被告知我需要一个 Qt 资源,我添加了该资源并解决了我的问题,图标确实显示在工具栏上。

现在我尝试使用相同的资源文件设置窗口的标题图标,它在 Qt 预览查看器中显示良好,但在实际程序中显示为空白。我正在使用一个具有 MDIArea 的 MainWindow,并且子窗口也是 MainWindows;父 MDI 和子 MDI 窗口图标都无法正确显示。在父级上,我看到常规的“Windows 应用程序图标”,而在子级上,该图标完全空白。

我该如何解决这个问题?

In my last question (Qt/C++: Icons not showing up when program is run) I asked how to get an icon to show up on a toolbar and was told I needed a Qt Resource, which I added and that fixed my problem, the icon did show up on the toolbar.

Now I'm trying to set the title icon of a window, using the same resource file, and it shows up fine in the Qt preview viewer but blank in the actual program. I am using a MainWindow which has an MDIArea and the children are MainWindows as well; neither the parent MDI nor child MDI windows icons will show properly. On the parent, I see the regular "Windows Application icon" and on the child, the icon is completely blank.

How can I solve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

好倦 2024-10-08 15:34:51

您必须浏览 Windows 的标准资源文件。 (即 .rc)

流程(如文档中所述) 是:

将 ICO 文件存储在应用程序的源代码目录中,以便
例如,名称为 myappico.ico。然后,创建一个名为的文本文件,
比如说,myapp.rc,您在其中放置了一行文本:

IDI_ICON1 图标可丢弃“myappico.ico”

最后,假设您使用 qmake 生成 makefile,请将此行添加到 myapp.pro

文件:RC_FILE = myapp.rc

重新生成您的 makefile 和应用程序。现在,.exe 文件将在资源管理器中用您的图标表示。

在 Visual Studio 中,您只需将资源添加到项目中即可。

You will have to go through a standard resource file for windows. (That is, a .rc)

The process (as described in the documentation) is:

Store the ICO file in your application's source code directory, for
example, with the name myappico.ico. Then, 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, 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.

In the Visual Studio case you're simply able to add a resource to your project.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文