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>
<RCC>
<qresource prefix="/images">
<file>images/lol.png</file>
</qresource>
</RCC>
To copy to clipboard, switch view to plain text mode
project file:
RESOURCES += \
qui.qrc
RESOURCES += \
qui.qrc
To copy to clipboard, switch view to plain text mode
and main.qml:
Image {
source: ":/images/images/lol.png"
}
Image {
source: ":/images/images/lol.png"
}
To copy to clipboard, switch view to plain text mode
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.
qDebug() << i->width();
QImage* i = new QImage(":/images/images/lol.png");
qDebug() << i->width();
To copy to clipboard, switch view to plain text mode
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
Bookmarks