Qt4 如何为我的应用程序添加 16px/32px/... 图标?

发布于 2024-10-22 04:33:21 字数 76 浏览 5 评论 0原文

如何为我的 Qt 应用程序设置图标? 我必须提供 16px、32px 等图标吗? 或者 Qt 会自动调整它们的大小以适应当前的要求吗?

how can I setup icons for my Qt application ?
Do I have to provide 16px,32px icons and so on ?
Or will Qt automagically resize them to fit current requirements ?

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

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

发布评论

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

评论(4

岁月苍老的讽刺 2024-10-29 04:33:21

您指的是应用程序图标,它在 Windows 中的可执行文件、任务栏和 alt+tab 上显示?

创建 yourprojekt.rc 并指向您的图标:

  IDI_ICON1 ICON DISCARDABLE "./youricon.ico"

在 projektfile 中建议 qmake 使用资源文件:

  RC_FILE = YourProjekt.rc

对于 youricon.ico 我建议包含 16px 的图标, 24 像素、32 像素、48 像素和 256 像素。 Afaik 是窗口使用的小符号 (16px) 到超大符号 (256px) 的尺寸。

如果你的 ico 中没有特定尺寸的图像,Windows 会将另一张图像调整为该尺寸 - 但在大多数情况下,将 32 像素放大或缩小到 256 像素看起来不太好。

You mean the application-icon, which is shown from windows for the executable, in taskbar and on alt+tab?

Create an yourprojekt.rc and point to your icon:

  IDI_ICON1 ICON DISCARDABLE "./youricon.ico"

In the projektfile advice qmake to use the resourcefile:

  RC_FILE = YourProjekt.rc

For the youricon.ico I recommend to include the the icon in 16px, 24px, 32px, 48px and 256px. Afaik are these the sizes used by windows for small symbols (16px) to extra large symbols (256px).

If you don't have an image of an particular size in your ico, windows will resize another one to that size - but upsizing or downsizung 32px to/from 256px does not look so nice in most cases.

简美 2024-10-29 04:33:21

编辑:看来您正在谈论顶级窗口的窗口图标。
可以使用QWidget::setWindowIcon()设置窗口图标,并且可以使用QApplication::setWindowIcon()设置新窗口的默认图标。如果您的源图像具有足够高的分辨率,Qt 应该自动调整该图标的大小以适应所有场合。

这在 Qt 文档 中进行了描述,包括有关如何设置嵌入图标的信息.exe 文件或 OS X 应用程序的。

Edit: It seems you're talking about the window icon of the top-level window.
Window icons can be set using QWidget::setWindowIcon(), and the default icon for new windows can be set using QApplication::setWindowIcon(). If your source image is of high enough resolution, Qt should automatically resize this icon for you to suit all occations.

This is described in the Qt documentation, including info about how to set the embedded icon of a .exe file or OS X application.

浅黛梨妆こ 2024-10-29 04:33:21

请记住,您可以在 *.ico 文件中存储多个图像。

有一个很好的免费工具来构建 ico 文件
http://icofx.ro

Remember that You can store multiple images in *.ico file.

There is a nice free tool to build ico files
http://icofx.ro

洛阳烟雨空心柳 2024-10-29 04:33:21

Qt 可以并且将会调整图标的大小。

将资源文件包含到您的项目中并使用资源编辑器添加图标。

Qt can and will resize the icons.

Include a resource file to your project and use the resource editor to add icons.

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