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. Referencing image files in Android
Forum Updated to NodeBB v4.3 + New Features

Referencing image files in Android

Scheduled Pinned Locked Moved Solved Mobile and Embedded
7 Posts 2 Posters 1.4k Views 3 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.
  • V Offline
    V Offline
    vlada
    wrote on last edited by
    #1

    I have a problem when referencing files in Android. I need to open images both in my C++ and QML part.

    On desktop I can use QUrl::fromLocalFile() in C++ and Qt.resolvedUrl() in QML and it works for both relative paths (to a subfolder in QML directory) and absolute path anywhere on the drive.

    On Android it won't work nor for the relative neither absolute path.

    Is there any universal solution for all systems and both relative and absolute paths?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vlada
      wrote on last edited by
      #2

      I solved the problem at QML side but I still can not find my files in C++ code. I can locate it on desktop using the path "qml/MyApp/images/image.jpg". But on Android using this path doesn't work. Do you have any idea what should be the correct path in Android? Thank you.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        What kind of files are we talking about here ? Your application own resources ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vlada
          wrote on last edited by
          #4

          Yes. I solved it using the resource system (adding them to a .qrc file) because this seems to be the only reliable cross platform solution. I didn't want to do that because I include the whole QML directory with all subdirectories (containing pictures) anyway. And I wanted to be able to change these pictures.

          But I was not able to figure out how to open a picture based on a relative path on Android. Probably it is because on Android the files are not stored relative to the executable but in another directory.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            You also have the Android assets alternative.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vlada
              wrote on last edited by
              #6

              Thank you. I will have a look at it. But I'll probably stay with the resource system as it is cross platform.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                As you wish :)

                In any case, since you have it working now, please mark the thread as solved using the "Topic Tools" so that other forum users may know a solution has been found :)

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0

                • Login

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