Adding images to the GUI of your custom QGIS 2.X plugin with Qt Designer

10 Apr 2017 ᛫ 1 min read


Sometimes we want or need to add images to our custom QGIS plugins, here’s how you do it.

It’s highly suggested that you use images that are already in the size that you want them to be in your plugin

1. Add the images you want to your resources.qrc file

Make sure that resources.qrc is located in the root folder of your plugin.

    <qresource prefix="plugins/name-of-plugin" >

2. Add the resources.qrc file to your GUI

Go to the Resource Browser located at the bottom right part of Qt Designer and click Edit Resources.

Click Open Resource File and select the resources.qrc file you created.

If there are no errors, you should be able to see the resources(images) that you added in the resources.qrc file. Click OK.

3. Use Labels to hold the images in your GUI

Add a Label widget. Delete the text.

On the Property Editor, go to QLabel -> pixmap and select Select Resource.

Select the image you want to add and edit the size of the Label on your GUI.

4. Compile your resources.qrc to

pyrcc resources.qrc -o

If you want to know why we compile it to, check here

5. Compile your *.ui files to *.py files

sudo python /usr/lib/python2.7/dist-packages/qgis/PyQt/uic/ name-of-file.ui -o

After this, you should be able to see the images you added in your GUI the next time you run your plugin in QGIS.


You may also like:

Mapping Icebergs in QGIS

Hillshade in QGIS

#MakeTheSwitch: Choose GeoPackage

Connecting QGIS to Remote Services (WFS, WMS, GeoNode, OSM): Hazard Mapping with Phil-LiDAR 1 and Project NOAH Hazard Maps on the Web