I am having issues creating a PyQt4 resources file to display images in my QGIS 2 custom feature form using Windows XP. These are the steps I followed:
-Added QLabel and clicked "choose resource…"
-Created my .qrc in PyQt4 designer, linked .png image file. Checked my file with notepad, and following lead of some tutorials made a few modifications (because it didn't work with the untouched resource file direct from PyQt4) My .qrc looks like this:
<!DOCTYPE RCC><RCC version ="1.0">
<qresource prefix="/">
<file>img/image.png</file>
</qresource>
</RCC>
-Saved the ui and compiled the resource file in the windows command line using:
pyrcc4 -o image_rc.py image.qrc
-I even tried compiling the ui to py and moved the import space_rc to the top
pyuic4 -o form.py form.ui
then:
import image_rc
the image is called like so:
self.label_7.setPixmap(QtGui.QPixmap(_fromUtf8(":/img/image.png")))
my file system structure is like so:
ui/resource.qrc
ui/form.ui
ui/img/image.png
Under my layer's properties in QGIS, I chose to add custom ui and linked to the ui created in PyQt designer. When opening the feature form, I see only my frame, but no image. After reading many tutorials on what steps to follow, I can't see what I am missing. Is there anything to be done in terms of Windows path environment variables?
img/image.png
, but then you useimg/Space.png
. could that be the error? – mataimage_rc
should be imported before the ui, that's the only thing I can think that could be wrong. – mata