Can't load Image source in QML Image

后端 未结 6 906
小鲜肉
小鲜肉 2021-02-07 03:08

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.

6条回答
  •  [愿得一人]
    2021-02-07 03:29

    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:

    enter image description here

    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).

提交回复
热议问题