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. Failed to get image from provider
Forum Updated to NodeBB v4.3 + New Features

Failed to get image from provider

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
19 Posts 4 Posters 3.3k Views 4 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.
  • SGaistS SGaist

    Hi,

    Did you check the id parameter content before just blindingly loading it ?

    G Offline
    G Offline
    gabor53
    wrote on last edited by
    #3

    @SGaist ,
    Yes. According to qDebug the content is

    MakePix requestPixmap id:  "file:///C:/Users/gabor/Pictures/133CANON/IMG_3344.jpg
    ``
    sierdzioS 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #4

      Hi
      The path seems wrong
      image://pix/file:///C:/Users/gabor/Pictures/133CANON/IMG_3344.JPG

      Why do you both add the image provider id (pix) and at the same time
      give it a fully qualified path to a file?

      This seems wrong to me ?
      image.source = "image://pix/" + fileDialog.fileUrl

      should it just not be ?
      image.source = fileDialog.fileUrl

      G 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        The path seems wrong
        image://pix/file:///C:/Users/gabor/Pictures/133CANON/IMG_3344.JPG

        Why do you both add the image provider id (pix) and at the same time
        give it a fully qualified path to a file?

        This seems wrong to me ?
        image.source = "image://pix/" + fileDialog.fileUrl

        should it just not be ?
        image.source = fileDialog.fileUrl

        G Offline
        G Offline
        gabor53
        wrote on last edited by
        #5

        Hi @mrjj ,
        I am trying to use the image provider that's why I used

        image.source = "image://pix/" + fileDialog.fileUrl
        ``
        I am trying to create a pixmap and use QML to save it to localstorage.
        mrjjM 1 Reply Last reply
        0
        • G gabor53

          Hi @mrjj ,
          I am trying to use the image provider that's why I used

          image.source = "image://pix/" + fileDialog.fileUrl
          ``
          I am trying to create a pixmap and use QML to save it to localstorage.
          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #6

          @gabor53
          Hi
          Ok, but are you sure the QQuickImageProvider should be involved in the
          saving of the image?
          The syntax "image://pix/" seems for loading only, docs mention nothing about saving.
          Anyway, i was just wondering.

          G 1 Reply Last reply
          0
          • G gabor53

            @SGaist ,
            Yes. According to qDebug the content is

            MakePix requestPixmap id:  "file:///C:/Users/gabor/Pictures/133CANON/IMG_3344.jpg
            ``
            sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #7

            @gabor53 said in Failed to get image from provider:

            @SGaist ,
            Yes. According to qDebug the content is

            MakePix requestPixmap id:  "file:///C:/Users/gabor/Pictures/133CANON/IMG_3344.jpg
            ``
            

            You need to remove file:/// from that URL, otherwise QPixmap won't handle it.

            As others note, however - it seems you don't need an image provider here at all. QML can handle JPG images out of the box.

            (Z(:^

            G 1 Reply Last reply
            0
            • sierdzioS sierdzio

              @gabor53 said in Failed to get image from provider:

              @SGaist ,
              Yes. According to qDebug the content is

              MakePix requestPixmap id:  "file:///C:/Users/gabor/Pictures/133CANON/IMG_3344.jpg
              ``
              

              You need to remove file:/// from that URL, otherwise QPixmap won't handle it.

              As others note, however - it seems you don't need an image provider here at all. QML can handle JPG images out of the box.

              G Offline
              G Offline
              gabor53
              wrote on last edited by
              #8

              Hi @sierdzio ,
              It is true, but how can I save the jpg to localstorage?
              Thank you.

              1 Reply Last reply
              0
              • sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #9

                You mean you want to take the jpg from one location and save it in another? Use QFile::copy().

                (Z(:^

                G 1 Reply Last reply
                0
                • sierdzioS sierdzio

                  You mean you want to take the jpg from one location and save it in another? Use QFile::copy().

                  G Offline
                  G Offline
                  gabor53
                  wrote on last edited by
                  #10

                  @sierdzio
                  I want to save the actual image to a db.

                  1 Reply Last reply
                  0
                  • mrjjM mrjj

                    @gabor53
                    Hi
                    Ok, but are you sure the QQuickImageProvider should be involved in the
                    saving of the image?
                    The syntax "image://pix/" seems for loading only, docs mention nothing about saving.
                    Anyway, i was just wondering.

                    G Offline
                    G Offline
                    gabor53
                    wrote on last edited by
                    #11

                    @mrjj,
                    The goal is to save the actual jpg into Qt Quick Local Storage. To do that I need to create a Blob from the jpg file. I don't think it is possible to do in QML; that's why I use QQuickImageProvider to send the image from QML to C++ and return a pixmap to QML.
                    If I copy 1.jpg to the qml folder and pass1.jpg to QQuickImageProvider the image is correctly displayed, which means the path I get from fileDialog.fileUrl is incorrect.
                    How can I fix the path so fileDialog.fileUrl provides the right path to the image?
                    Thank you.

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

                      @sierdzio already answered that question.

                      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
                      • mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #13

                        hi
                        so you get a pixmap back to QML but how do you then convert it to the blob?
                        As far as i understand, Qt Quick Local Storage is a sqllite database so
                        you need it as QbyteArray to save it.

                        G 1 Reply Last reply
                        0
                        • mrjjM mrjj

                          hi
                          so you get a pixmap back to QML but how do you then convert it to the blob?
                          As far as i understand, Qt Quick Local Storage is a sqllite database so
                          you need it as QbyteArray to save it.

                          G Offline
                          G Offline
                          gabor53
                          wrote on last edited by
                          #14

                          @mrjj
                          Is there a way to convert pixmap into blob in QML?

                          mrjjM 1 Reply Last reply
                          0
                          • G gabor53

                            @mrjj
                            Is there a way to convert pixmap into blob in QML?

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

                            @gabor53
                            Hi
                            sadly i dont know QML well enough to answer that.
                            It seems it get converted to ArrayBuffer if used in signals.
                            from c++ to QML.
                            but im not sure how you can get the pixmap into that.

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

                              Did you already check Qt Quick Local Storage QML Types ?

                              By the way, why do you want to store images there ?

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

                              G 1 Reply Last reply
                              0
                              • SGaistS SGaist

                                Did you already check Qt Quick Local Storage QML Types ?

                                By the way, why do you want to store images there ?

                                G Offline
                                G Offline
                                gabor53
                                wrote on last edited by gabor53
                                #17

                                @SGaist ,
                                I checked Local Storage QML Types but it doesn't really talk about images.
                                I'm creating a small app where I can store an image and a description of the image. I used to do it by storing only the url, but eventually the images got moved and I ended up with a bunch of broken links.

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

                                  In that case, I would rather go with a more classical approach through C++ especially if you want to recover the images.

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

                                  G 1 Reply Last reply
                                  2
                                  • SGaistS SGaist

                                    In that case, I would rather go with a more classical approach through C++ especially if you want to recover the images.

                                    G Offline
                                    G Offline
                                    gabor53
                                    wrote on last edited by
                                    #19

                                    @SGaist
                                    Thank you. I will do it that way.

                                    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