Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm unable to setup the display of the toolbar icon for a plugin in QGIS 2.0. I have compiled the "resources.qrc" with the correct path and filename, and checked possible spelling errors in the code.

In fact, the icon is displayed in the plugin manager but not on the toolbar or the dropdown menu (?). The plugin has been started using the plugin builder for 1.8 version, but works just fine. The plugin folder is linked to the qgis plugins folder by a symlink on a linux system.

Thanks.

Edit: my qrc file :

<RCC>
    <qresource prefix="/plugins/ViewshedAnalysis" >
        <file>icon.png</file>
    </qresource>
</RCC>

and my code :

self.action = QAction(
        QIcon(":/plugins/ViewshedAnalysis/icon.png"),
        u"Viewshed", self.iface.mainWindow())
QObject.connect(self.action, SIGNAL("triggered()"), self.run)


# Add toolbar button and menu item
self.iface.addToolBarIcon(self.action)
self.iface.addPluginToMenu(u"&Viewshed Analysis", self.action)
share|improve this question

closed as off-topic by underdark Jul 11 at 21:58

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – underdark
If this question can be reworded to fit the rules in the help center, please edit the question.

    
What do you see in the icons place? Nothing? –  Nathan W Dec 10 '13 at 12:12
    
yes, it's empty –  Zoran Dec 10 '13 at 13:06
    
Can you past your resources.qrc and and example of you loading the icon. –  Nathan W Dec 10 '13 at 13:07
2  
did you import your compiled resource? import resources_rc –  Matthias Kuhn Dec 11 '13 at 9:10
1  
Bingo! I do import the resources, but with a small typo ... so now it works perfectly! (I would never figure thos out :) –  Zoran Dec 12 '13 at 13:26

1 Answer 1

Worked for myself as well, as Matthias suggested if you add the following to your import statements:

import resources_rc

It works as long as you have updated and recompiled your resources file:

pyrcc4 -o resources_rc.py resources.qrc

(In windows easiest to run with the OSGeo4W shell, cd to directory)

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.