Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Database BLOB to Image in Qml
Forum Updated to NodeBB v4.3 + New Features

Database BLOB to Image in Qml

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 2 Posters 959 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.
  • S Offline
    S Offline
    sandro4912
    wrote on 25 Sept 2020, 16:20 last edited by
    #1

    So I have an SQL Database which contains an Picture stored as a BLOB.

    What is the easiest way to show it in an Image in QML ?

    I already can expose the data to QML as QByteArray but how to load that in an Image?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 26 Sept 2020, 11:05 last edited by
      #4

      You can try the technique described here.

      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
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 25 Sept 2020, 18:15 last edited by
        #2

        Hi,

        What about a custom image provider ?

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

        S 1 Reply Last reply 26 Sept 2020, 05:32
        1
        • S SGaist
          25 Sept 2020, 18:15

          Hi,

          What about a custom image provider ?

          S Offline
          S Offline
          sandro4912
          wrote on 26 Sept 2020, 05:32 last edited by sandro4912
          #3

          @SGaist Can I provide to that one If I get the data in QML as QByteArray? I expose a struct with other data aswell to QML and one contains the QByteArray.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 26 Sept 2020, 11:05 last edited by
            #4

            You can try the technique described here.

            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
            • S Offline
              S Offline
              sandro4912
              wrote on 27 Sept 2020, 08:54 last edited by
              #5

              I followed the instructions in the link you provided and it worked well.

              I just don't understand how you would came up with passing

              "data:image/png;base64,"
              

              to Image. I think that should be in the docs of Image.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 27 Sept 2020, 09:01 last edited by
                #6

                That is the way to fully embed an image in a web page without the need for a remote file but it makes the size of the data at least twice as big.

                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

                1/6

                25 Sept 2020, 16:20

                • Login

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