简体   繁体   中英

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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