Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Where is my image?
Forum Updated to NodeBB v4.3 + New Features

Where is my image?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
5 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kgregory
    wrote on last edited by
    #1

    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?

    A 1 Reply Last reply
    0
    • K kgregory

      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?

      A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

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

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kgregory
        wrote on last edited by
        #3

        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
                }
            }
        
        1 Reply Last reply
        0
        • A Offline
          A Offline
          ambershark
          wrote on last edited by
          #4

          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.

          My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

          1 Reply Last reply
          5
          • K Offline
            K Offline
            kgregory
            wrote on last edited by
            #5

            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!

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved