Show image from assets in QML
Mobile and Embedded
3
Posts
2
Posters
2.6k
Views
2
Watching
-
Hi,
I'm bundling a lot of *.jpg images in my application as Android assets, as described in http://doc.qt.io/qt-5/platform-notes-android.html
How can I show the images in QML Image element? The above page states that I should be able to access them by prefixing the file withassets:/. This works in C++, but not in QML.
I tried code like this in various variants:Image { anchors.fill: parent source: "file://assets:/be_01.jpg" fillMode: Image.PreserveAspectCrop asynchronous: true }Unfortunately I can't use resource system for the images because they have around 100 MB in size.
EDIT: I also tried to add this C++ code to find out absolute path of the file:
QFile dbFile("assets:/be_01.jpg"); qDebug() << dbFile.exists(); QFileInfo info(dbFile); qDebug() << info.absoluteFilePath();This just prints
true,"assets:/be_01.jpg". -
Hi,
Do you mean that
source: "assets:/be_01.jpg"doesn't work ?