PyQt5 打包 没有icon图标

PyQt5打包成exe,双击打开的任务栏和窗口都没有显示图标。解决方案:

1、创建images.qrc文件,写入以下内容:

<RCC> 
    <qresource prefix="/"> 
        <file>pig128.png</file>
     </qresource> 
</RCC>

2、生成py文件,这个py文件把图片保存成二进制:

pyrcc5 images.qrc -o images.py

3、导入模块,设置图标

import images


self.setWindowIcon(QIcon(':/pig128.png'))

参考:https://blog.csdn.net/wltsysterm/article/details/104637829

原文地址:https://www.cnblogs.com/jingsupo/p/13536449.html