Can't load Image source in QML Image

后端 未结 6 924
小鲜肉
小鲜肉 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:33

    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:/image.png"
    

提交回复
热议问题