pythonqtresourcespyqt4qicon

Create QIcon from resources.qrc file


I have a resources.qrc file that looks like this:

<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

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

and then put it on a QPushButton with

self.pushButton_toggle_epl_view.setIcon(icon)

but no Icon is displayed. What am I missing? Wrong path?


Solution

  • Your path is wrong, try this instead :

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