[Interest] QML Image Resources and Qt Quick Designer

William Hallatt goblincoding at gmail.com
Wed Aug 27 17:39:48 CEST 2014


Good day everyone,

I have continued playing with various combinations of resource files,
directory structures and resource prefixes since none of my searches so far
have returned anything of use.  Having said that, I have had absolutely no
luck yet either.

Initially I tried a separate resource file for images with a separate
directory outside of that of the qml resource and files, but this bombs as
described below.  I have subsequently also attempted to include a new
directory within the qml resource directory for images alone (and adding
these images to the existing qml resource file), but this fails in a
similar manner.  I then attempted to dump all the images in the same
directory as that of my qml files, add them to the qml resource and only
filter them on the QtCreator side with their own separate prefix, but the
results are the same.

In short, I am yet to figure out a way where I can have my images separate
from my qml in a manner that I do not run into the "cannot open" error *and
*view the qml correctly in Qt Quick Designer as it should be.  So far, the
only way I can have my bread buttered on both sides (in terms of avoiding
the error and viewing the qml in Qt Quick Designer) is to dump everything
into the same directory and in the same resource file.  This, however, is
not neat and tidy:


[image: Inline images 1]


If anybody has any input to offer, I would appreciate it...

Regards,
William.




On 26 August 2014 13:06, William Hallatt <goblincoding at gmail.com> wrote:

> Good day everyone,
>
> I am attempting to set up a QML/QtQuick test app and have run into some
> issues when using resources for images.
>
> If I add my .png's to a resource file and reference them from within QML
> using the "qrc:/images/background.png" route, then I can run the app no
> problem BUT I cannot see the image when viewing the QML file in Designer.
>
> If I use Designer to browse to the png, then I can see the image in
> Designer, but trying to run the app results in the following error: "qrc:/main.qml:14:9:
> QML Image: Cannot open: qrc:/images/background.png"
>
> (I am assuming it is due to Designer changing the source reference to
> "../images/background.png")
>
> What I would like to know is how I can reference "resourced" images from
> within Designer so that I may have both?  I have tried Googling, but have
> had no luck to date.
>
> Attached is a zip archive of my test app.
>
> Kind regards,
> William Hallatt
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140827/d338a92d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 16587 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140827/d338a92d/attachment.png>


More information about the Interest mailing list