0
votes

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?

1
in your qrc you have img/image.png, but then you use img/Space.png. could that be the error?mata
@mata excuse me, that was a typo for this post. the image file names do correspond well in my situation, thus is not the erroruser25976
yea, thought so. hmmm, from what I can see it should work. very strange... image_rc should be imported before the ui, that's the only thing I can think that could be wrong.mata
@mata possibility of a pathname environment variable interference due to GDAL?user25976

1 Answers

0
votes

It turns out there's an interference between PyQt and GDAL in terms of Windows environment paths. I got this to work after moving C:\Program Files\GDAL to the end of the variable value list. Not sure how GDAL related applications are going to react, however.