简体   繁体   English

从 resources.qrc 文件创建 QIcon

[英]Create QIcon from resources.qrc file

I have a resources.qrc file that looks like this:我有一个如下所示的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>

I want to create a QIcon from these resources with我想从这些资源中创建一个 QIcon

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

and then put it on a QPushButton with然后把它放在一个 QPushButton 上

self.pushButton_toggle_epl_view.setIcon(icon)

but no Icon is displayed.但没有显示图标。 What am I missing?我错过了什么? Wrong path?走错路?

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM