Instead of asking, I should have gone drinking a coffee or do some sports. It's an embarrassing beginner's problem. Still, there might be others like me...
My QtQuick application consisted of essentially of a C++ source file main.cpp, a resource file qml.qrc and an image foo.png.
Source file (the shown code is generated automatically by QtCreator):
//main.cpp
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
return app.exec();
}
Resource file with additional prefix for images:
//qml.qrc
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
<qresource prefix="/images">
<file>images/foo.png</file>
</qresource>
</RCC>
A qml file, where I want to import an image:
//main.qml
import QtQuick 2.2
import QtQuick.Window 2.0
Window {
visible: true
Image {
source: ???
}
}
My problem was that I didn't know what to write instead of ??? in the .qml file. To import the graphic you need to write "/images/images/foo.png", but my mind revolted against the idea of writing /images twice.
Thanks.