Qt应用程序和窗口下的窗口图标 [英] Qt Application and window Icon under windows

查看:161
本文介绍了Qt应用程序和窗口下的窗口图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过嵌入包含图标的标准Windows资源文件创建了一个简单的应用程序图标。但是,我还想在我的主应用程序窗口中使用此图标。是否有捷径可寻?到目前为止,似乎唯一的方法是单独加载包含窗口图标的图标,而不是重复使用已经存在的图标。这似乎是一个可怕的解决方案。除了其他的东西,实际的图标嵌入在我的可执行文件中我不想分发它两次。

I have created a simple application icon by embedding a standard windows resource file containing an icon. However I would also like to use this icon on my main application window. Is there an easy way to do this? So far it seems the only way would be to seperately load an icon that contains the window icon rather than reusing the already exisiting icon. This seems like a horrible solution. Amongst other things the actual icon is embedded in my executable I don't want to have to distribute it twice.

任何人都知道怎么做?

推荐答案

实际上......结果非常简单......

Actually ... turns out its very very simple ...

HICON       hIcon   = (HICON)LoadImage( GetModuleHandle( nullptr ), MAKEINTRESOURCE( IDI_ICON1 ), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADTRANSPARENT );

setWindowIcon( QIcon( QtWin::fromWinHICON( hIcon ) ) );

::DestroyIcon( hIcon );

这篇关于Qt应用程序和窗口下的窗口图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆