3

I'm using QGIS 3.1 and I created a plugin. Finally, I want to add a image(.png) to my plugin's GUI with Qt Designer. But when I add it, QGIS gives an error when it opens and my plugin does not work.

These is my steps:

  • First, I open my "...base.ui" file with Qt Designer and I create a empty label enter image description here

  • Image source selection with pixmap enter image description here

    enter image description here

  • Scale to image and saving after that enter image description here

------- Errors -------------- enter image description here

--- My compile.bat and recources.qrc files ---- enter image description here enter image description here

Edit: ---Error Messages as text format---

Couldn't load plugin 'save_attributes' due to an error when calling its classFactory() method 

TypeError: qRegisterResourceData(int, bytes, bytes, bytes): argument 2 has unexpected type 'str' 

(Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] 
QGIS version: 3.10.3-A Coruña A Coruña, 0e1f846438 )

Note: Maybe the method that I applied was wrong. I can try to image adding with different way, if you tell me.

3
  • @KadirŞahbaz I edited my post and added errors as text format on last part.
    – AFK
    Commented Dec 11, 2020 at 5:01
  • Did you try choosing the image with "choose file" instead of "choose resource" ?
    – JULESG
    Commented Dec 11, 2020 at 8:20
  • @JULESG yes I tried and this way, it does not give an error and plugin is working. but the image does not appear on the GUI
    – AFK
    Commented Dec 11, 2020 at 10:13

1 Answer 1

5

I found a solution with the help of this post.

It worked for me. I'm on QGis 3.16, I hope it's the same for the 3.10 version.

Once you've added the resource image. You need to open the file save_attributes_dialog_base.ui with a text editor and look for a ressources element. Like this one :

enter image description here

This is the cause of the problem. You have to empty the element. Like this :

enter image description here

Save your file. Go to QGis, refresh your plugin and you're good !

3
  • I tried to your solution. no longer gives an error, my plugin opens. but the image is not appear where I put on the GUI. ss: i.ibb.co/hcsFb0r/Screenshot-5.png
    – AFK
    Commented Dec 11, 2020 at 11:32
  • @AFK Did you try to put another image ? maybe with another format ?
    – JULESG
    Commented Dec 11, 2020 at 11:47
  • no but it works now. I rerun again my compile.bat file and tried again to your solution, finally it works. thnx
    – AFK
    Commented Dec 11, 2020 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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