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.

comments powered by Disqus

You may also like:

Why You Shouldn't Use QGIS

22 Oct 2019 ᛫ 1 min read

Geotagged Photos in QGIS

22 Sep 2019 ᛫ 4 min read

Bivariate Choropleth Maps in QGIS

15 Sep 2019 ᛫ 5 min read

#PistaNgMapa: Beyond the Basics with QGIS 3.X

02 Aug 2019 ᛫ 1 min read

#PluginFridays: MapSwipe Tool

29 Mar 2019 ᛫ 2 min read


[email protected]

Creative Commons License
This work and its contents by Ben Hur S. Pintor is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Other works (software, source code, etc.) referenced in this website are under their own respective licenses.
This site is powered by Jekyll and hosted on Github (view source)