[PyQt] Absolute paths in qrc file.

Eric Frederich eric.frederich at gmail.com
Fri Jun 28 22:14:20 BST 2013


Thanks, I think a symlink will work great.
I'll just symlink to /usr/share/icons in my main directory.

I'd love to be able to use QIcon.fromTheme but I'm on RHEL 6 it is unavailable.
What is weird though is that it is available in Qt 4.6.2 but not PyQt 4.6.2
I thought that PyQt built bindings for whatever the Qt libs had available.

Qt: 4.6.2
SIP: 4.9.3
PyQt: 4.6.2

Also, I found that putting a bunch of ../../../../ in front of the
path worked too but that is obviously error-prone should your project
be deep in a filesystem

On Fri, Jun 28, 2013 at 12:08 PM, Baz Walter <bazwal at ftml.net> wrote:
> On 28/06/13 15:45, Eric Frederich wrote:
>>
>> I'm having trouble working with absolute file paths in my qrc resource
>> file with PyQt.
>> Am I doing something wrong or is it just something that rcc happens to
>> support but not pyrcc4?
>>
>> Here is my resource file
>>
>>      $ cat resources.qrc
>>      <!DOCTYPE RCC><RCC version="1.0">
>>      <qresource>
>>      <file
>> alias="filesaveas.png">/usr/share/icons/oxygen/32x32/actions/document-save-as.png</file>
>>      </qresource>
>>      </RCC>
>>
>> When I invoke pyrcc4:
>>
>>      $ pyrcc4 -o qrc_resources.py resources.qrc
>>      Cannot find file:
>> /usr/share/icons/oxygen/32x32/actions/document-save-as.png
>>      No resources in resource description.
>>
>> The file does exist:
>>
>>      $ file /usr/share/icons/oxygen/32x32/actions/document-save-as.png
>>      /usr/share/icons/oxygen/32x32/actions/document-save-as.png: PNG
>> image data, 32 x 32, 8-bit/color RGBA, non-interlaced
>>
>> Note: rcc works fine with this file:
>>
>>      $ rcc resources.qrc -o resources.rcc
>>      $ wc -l resources.rcc
>>      199 resources.rcc
>
>
> Don't know about rcc, but the Qt docs are pretty clear that relative paths
> must be used in qrc files:
>
>
> https://qt-project.org/doc/qt-4.8/resources.html#resource-collection-files
>
> I suppose you could just use a symlink to work around this.
>
> PS: For standard icons, a possible alternative solution is to use
> QIcon.fromTheme (only really useful on Linux, though):
>
>     https://qt-project.org/doc/qt-4.8/qicon.html#fromTheme
>
> --
> Regards
> Baz Walter
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt


More information about the PyQt mailing list