Including Image as a package
-
Hi,
My query was if we can include all the images used in my qml files as a separate package,
if we can,what are the changes to be done in our qml files and is it necessary to include them in the .qrc file ?
Will it be possible to run it in Desktop as well as in embedded environment.? -
You have practically answered yourself already :-)
Yes, to ship images in a package, it's easiest to use QRC files - then you have them bundled with executable (or you can ship an external QRC file, too).
Yes it will work on any operating system, including embedded.
-
Hi @sierdzio ,
Thank you for the answer,there is one more question in the same context, if I am including images as an external package, then i will have to include the images as "file:///image.png"
Is there any disadvantage of dynamically setting the source of the image , for example,
what is the difference between "qrc:/image.png" and "file:///image.png". Is there any disadvantage in using file:///image.png? -
@Anita said in Including Image as a package:
there is one more question in the same context, if I am including images as an external package, then i will have to include the images as "file:///image.png"
Note: not necessarily. You can dynamically load a QRC file and then you will still use the
qrc:/
call.Is there any disadvantage of dynamically setting the source of the image , for example,
what is the difference between "qrc:/image.png" and "file:///image.png". Is there any disadvantage in using file:///image.png?There is not much difference from user perspective, both approaches work. Using QRC is usually easier to implement because you don't need to worry about deploying the images (esp. hard on mobile platforms), you don't need to even check if image file exists because you know it does. But if you set it up correctly, both solutions will work great.
One additional advantage of QRC is that you can use aliases to "overload" certain images - use single path like
:/img/logo.jpg
but display different file depending on which QRC file was loaded. Similar results can be achieved using file selectors, though, too.