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. Problem Displaying image on Android
Forum Updated to NodeBB v4.3 + New Features

Problem Displaying image on Android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
7 Posts 3 Posters 919 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.
  • A Offline
    A Offline
    Alfie Anil
    wrote on last edited by
    #1

    Hello everyone, I'm having problems displaying images on an android device.
    I initially used QPixmap and gave the location of the image on my computer drive, but that didn't work (didn't show image on the phone), and then I tried using the resource file with the .qrc. Using the resource file worked, however, I need to be able to change the image as the image will change daily. Is there any code that I can write to change the image in the .qrc file, keeping the same link? Or any alternative methods?

    As always any help is Greatly Appreciated.
    Thank you

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      QRC files are readonly so you cannot write the image back to it.

      However, you can use
      https://doc.qt.io/qt-5/qstandardpaths.html
      to find a place where you have to write access and then save it there.
      (and load from there )

      1 Reply Last reply
      1
      • A Offline
        A Offline
        Alfie Anil
        wrote on last edited by
        #3

        Thank you, I'm not too familiar with QStandardPaths though, so do you know of any other methods, in which I can read and change the file?
        Thanks

        mrjjM SGaistS 2 Replies Last reply
        0
        • A Alfie Anil

          Thank you, I'm not too familiar with QStandardPaths though, so do you know of any other methods, in which I can read and change the file?
          Thanks

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Alfie-Anil
          Hi
          To save the changed image, you do need a writable folder so not sure there is a better way.
          Also its just
          QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
          or similar

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Alfie Anil
            wrote on last edited by Alfie Anil
            #5

            I'm not sure if this is useful information, but there is a python file that does some webscraping and stores the image in the same folder as the qt c++ file. So is there any way that I could get that Image without directly writing the path in QPixmap because I think that the problem arises when I have to specify the path? (p.s sorry about inconvenience)

            mrjjM 1 Reply Last reply
            0
            • A Alfie Anil

              I'm not sure if this is useful information, but there is a python file that does some webscraping and stores the image in the same folder as the qt c++ file. So is there any way that I could get that Image without directly writing the path in QPixmap because I think that the problem arises when I have to specify the path? (p.s sorry about inconvenience)

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @Alfie-Anil
              Hi
              Is that py file with the app exe file ?
              You can get path of exe with
              qDebug() << "App path : " << qApp->applicationDirPath();
              and see if that is same folder.
              If you can write there , it could be used also. ( i doubt you can write there )

              1 Reply Last reply
              0
              • A Alfie Anil

                Thank you, I'm not too familiar with QStandardPaths though, so do you know of any other methods, in which I can read and change the file?
                Thanks

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @Alfie-Anil said in Problem Displaying image on Android:

                Thank you, I'm not too familiar with QStandardPaths though, so do you know of any other methods, in which I can read and change the file?
                Thanks

                Hi,

                You better learn to use it. On mobile devices you won't be able to write in the folder where your application reside. This is also valid for default installation on desktop environments.

                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
                1

                • Login

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