PDA

View Full Version : Image resource lookup in OS X



stipa
30th November 2010, 00:38
Hi,

I've created new QtQuick application with latest Qt SDK for OS X and with lastest Qt Creator.

I have image lol.png, located in /images dir under project root dir.

I have resource file:


<RCC>
<qresource prefix="/images">
<file>images/lol.png</file>
</qresource>
</RCC>


project file:


RESOURCES += \
qui.qrc


and main.qml:


Image {
source: ":/images/images/lol.png"
}


However, when I run project, I got error message:


file:///xxxxxxxxx/qui-build-desktop/qui.app/Contents/Resources/qml/qui/main.qml:8:5: QML Image: Cannot open: file:///images/images/lol.png


When I use same resource scheme and try to load resource in main.cpp, everything works fine.


QImage* i = new QImage(":/images/images/lol.png");
qDebug() << i->width();


I checked output build directory, ../qui-build-desktop, there is file qrc_qui.cpp, that contains my image resource, with comments containing scheme from above.

My question is - why resource cannot be loaded from qml?

Thanks,

-Lev

bezstellar
1st December 2010, 09:11
try this:

Image {
source: "qrc:/images/images/lol.png"
}