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. Android deployment... how to deploy images for app to load
Forum Updated to NodeBB v4.3 + New Features

Android deployment... how to deploy images for app to load

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 3 Posters 654 Views 2 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.
  • D Offline
    D Offline
    dogbear
    wrote on 27 Jan 2019, 18:05 last edited by
    #1

    Hi.

    I have a QtQuick app that loads an image from disk and displays it.

    On the desktop, no problem deploying. I have an "images" directory in the same directory as the exe and I use the source "file:./images/myimage.png" and all is well.

    But I can't deploy to Android. I have tried to add a "drawable" directory to the "res" directory with my image in it but it keeps getting deleted and reset when I go to deploy.

    What's the secret? Do I need to adjust AndroidManifest.xml? Do I need to add something to the .pro file?

    And will my app be able to load the image by making an Image.source = "file:./res/drawable/myimage.png"??

    Again, very simple QtQuick, as the following qml shows:

    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Test Android")
    
        Rectangle {
            id: mainRect
            anchors.fill: parent
            color: "blue"
    
            Image {
                id: mainImage
                anchors.centerIn: mainRect
                width: mainRect.width * 0.5
                source: "file:./drawable/myimage.png"
                fillMode: Image.PreserveAspectFit
            }
    
        }
    
    }
    

    Please help!

    Thanks.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      morte
      wrote on 27 Jan 2019, 19:03 last edited by
      #2

      Hi, use qrc files for images. Add your stuff to qrc file then it will be compiled and deployed. http://doc.qt.io/qt-5/resources.html

      D 1 Reply Last reply 29 Jan 2019, 18:43
      1
      • M morte
        27 Jan 2019, 19:03

        Hi, use qrc files for images. Add your stuff to qrc file then it will be compiled and deployed. http://doc.qt.io/qt-5/resources.html

        D Offline
        D Offline
        dogbear
        wrote on 29 Jan 2019, 18:43 last edited by
        #3

        @morte Thanks for that but I do not want to compile the images into the executable any more. You see I had already done this, adding many, many images to the qrc, and, eventually, when it got too big, the compiler ran out of heap space. It's better if I can just load the images from disk at runtime.

        R 1 Reply Last reply 29 Jan 2019, 20:12
        0
        • D dogbear
          29 Jan 2019, 18:43

          @morte Thanks for that but I do not want to compile the images into the executable any more. You see I had already done this, adding many, many images to the qrc, and, eventually, when it got too big, the compiler ran out of heap space. It's better if I can just load the images from disk at runtime.

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 29 Jan 2019, 20:12 last edited by raven-worx
          #4

          @dogbear said in Android deployment... how to deploy images for app to load:

          It's better if I can just load the images from disk at runtime.

          and much slower.

          Anyway you can add the images to the assets folder and access them (even out of QML iirc) with an asset:// url

          https://community.kde.org/Necessitas/Assets

          The assets folder can be found in the path you specified via ANDROID_PACKAGE_SOURCE_DIR qmake variable

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          1

          1/4

          27 Jan 2019, 18:05

          • Login

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