Joc*_*rze 1 python resources qt pyqt4 qicon
我有一个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>
Run Code Online (Sandbox Code Playgroud)
我想从这些资源创建一个 QIcon
icon = QIcon('qrc:///route.png')
Run Code Online (Sandbox Code Playgroud)
然后把它放在 QPushButton 上
self.pushButton_toggle_epl_view.setIcon(icon)
Run Code Online (Sandbox Code Playgroud)
但没有显示图标。我缺少什么?路径错误?
您的路径错误,请尝试以下操作:
icon = QIcon(":/plugins/fw_einsatz/route.png")
Run Code Online (Sandbox Code Playgroud)