从 resources.qrc 文件创建 QIcon
Create QIcon from resources.qrc file
我有一个 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")
我有一个 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")