2

My UT QML project makes use of a set of images, and I was planning use them via "qrc:///pathtoimages/myimage.png" style of url.

In Ubuntu SDK, I can "add new... Qt / Qt Resource File".
The file is created, but then I get the following error saying:

enter image description here

  • What does the error mean?
  • Can I safely ignore it?
  • Will the package generation include my images?

[EDIT] After further investigation, it seems that using qt resources files only makes sense when using qmake, to embed some file into the binary. So it might be just useless in Ubuntu SDK.

Sylvain Pineau
  • 61,564
  • 18
  • 149
  • 183
alci
  • 5,761
  • 6
  • 42
  • 65

1 Answers1

1

You can manage resource files with the Qt resource system, but it's only meant to be use for applications mixing QML AND C++, not for projects started as simple Touch UI:

The Qt resource system allows resource files to be stored as binary files in an application executable. This can be useful when building a mixed QML/C++ application as it enables QML files (as well as other resources such as images and sound files) to be referred to through the resource system URI scheme rather than relative or absolute paths to filesystem resources.

For projects only made of QML files, the way to use images resource is by using relative paths in your QML application, e.g:

Image {
    anchors.fill: parent
    source: "../../svg/test.svg"
}

All images files will be included automatically by the <My_project>.qmlproject file.

Sylvain Pineau
  • 61,564
  • 18
  • 149
  • 183
  • Hi Sylvain, sorry to be a pain & point you at my own question but it _is_ related [http://askubuntu.com/questions/777348/ubuntu-sdk-having-difficulty-getting-images-to-work-in-qml-only-app-when-dep] When deployed to Desktop the `source: "Pics/testpic.png"` works fine but not when deployed to armhf device where it says `QML QQuickImage: Cannot open: file:///opt/click.ubuntu.com` etc – pHeLiOn May 29 '16 at 21:16
  • @pHeLiOn Sorry for the late reply, please try to ask your question on the phone mailing list, ubuntu-phone@lists.launchpad.net. You'll get a wider (developer) audience for this kind of issues. – Sylvain Pineau May 31 '16 at 08:53