This seems really basic but for some reason I can\'t get the image source to work in the ultra-simple QML app below.
FYI, I\'m running Mac OS-X 10.9.5, Qt Creator 3.2.
I suppose that your qml
file is in resources, so try place your testImage.png
image in resources too. Recompile app, run it and check is image works properly.
All should be together. For example:
My code:
Image
{
source: "images/earth.png"
If I delete this image from resources, I'll get this error too, but image still in the correct place in file system.
When qml
source placed in the resource, then all files, which loads from qml
should be in resource too (Qt searchs this files in the resources, not in the file system).
If you are using qrc, make sure the image is added to your project. Just having it in your source directory may not be enough. For example, my main.qml is located in a particular directory. I move my .png into the same directory. I then "Add Existing Files.." and add the .png to the project. My image has the following
source:"qrc:<same dir as main.qml>/image.png"
Try to close Shadow Build under Projects->Build Settings.
If you are locating from local filesystem , get the file path and prefix "file:" as source = "file:/root/Desktop/Rathod.png"
There can be two problems:
IconImage
refuses to load it. Try to use another image that is known as work correctly
It seems that the Qt Image loader is very sensitive to the image format.qml_qmlcachea.qrc
in your compiling folder and try it againI had a similiar problem and solved it the following way: