Where is my image?

  • I'm a total newbie at both Qt and mobile app development. I created a new Qt Quick2 application and compiled it as release on my phone. The only change I have made from the blank project was to add an image. The image doesn't show on my phone. Do I need to include some package for the image to load or something?

  • Moderators

    @kgregory How did you show the image? Show us the code for that. Also did you include the image in a resource file? If so, show us the code for your qrc.

  • I just edited the layout in the designer tab. Other objects that I added that way showed up (albeit much smaller than in the designer view), so I was assuming that was all I had to do. Below is the code that was generated in MainForm.ui.qml. I added the image as a resource file, but it still doesn't show up.

    Flickable {
            id: flickable
            x: 5
            y: 202
            width: 351
            height: 119
            Image {
                id: image
                x: 0
                y: 0
                width: 351
                height: 119
                sourceSize.height: 100
                sourceSize.width: 300
                fillMode: Image.PreserveAspectFit
                source: "myimage.png"
            Text {
                id: text1
                x: 164
                y: 53
                text: qsTr("Flick me!")
                font.pixelSize: 12

  • Moderators

    Ok yea my guess is "myimage.png" doesn't exist on the device. You can add that image to a resource file and then reference it with something like:

    Image {
       source: "qrc:/myimage.png"

    That should show it.

    The other option is to make sure you upload the myimage.png to your application's directory on the target system. Then it should load with your existing code.

  • That did it! I guess I added it the wrong way and it showed up in "other files". I didn't know I could edit the resource file. Thanks!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.