gpt4 book ai didi

python - 从 resources.qrc 文件创建 QIcon

转载 作者:太空宇宙 更新时间:2023-11-04 10:10:17 25 4
gpt4 key购买 nike

我有一个 resources.qrc 文件,如下所示:

<RCC>
<qresource prefix="/plugins/fw_einsatz">
<file>base_aerial.png</file>
<file>base_alkis.png</file>
<file>adr.png</file>
<file>gps_coord.png</file>
<file>road.png</file>
<file>route.png</file>
<file>icon.png</file>
</qresource>
</RCC>

我想用这些资源创建一个 QIcon

icon = QIcon('qrc:///route.png')

然后把它放在一个 QPushButton 上

self.pushButton_toggle_epl_view.setIcon(icon)

但没有显示图标。我错过了什么?路径错误?

最佳答案

你的路径是错误的,试试这个:

icon = QIcon(":/plugins/fw_einsatz/route.png")

关于python - 从 resources.qrc 文件创建 QIcon,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38747744/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com