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

ERROR: Failed to get image from provider

Scheduled Pinned Locked Moved Solved QML and Qt Quick
8 Posts 3 Posters 6.4k 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.
  • L Offline
    L Offline
    literA2
    wrote on last edited by literA2
    #1

    Hi,

    I am trying to load either of the two images using QuickImageProvider. However, I am having this error in my log, is there a way to prevent it from showing.

    Here is my code, it works fine but with this error only. The error appeared once it loads "image2.png" which is can be null image (as expected because it comes from settings file in base64 format) or not. I used the statusChanged handler but seems that the error happened first before the status changes.

    Maybe you can advise a different approach.

    Image {
      source: "image:://provide/image1.png"
       onStatusChanged: {
         if (status == Image.Error) { source = "image:://provide/image1.png" }
       }
        Component.onCompleted: {
           source = "image:://provide/image2.png";
        }
    }
    
    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      If you are using the imageProvide you need to used the syntax like
      "image://<registereimageprovidername>/image.png"

      May be it is hitting issue because of this.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      L 1 Reply Last reply
      5
      • dheerendraD dheerendra

        If you are using the imageProvide you need to used the syntax like
        "image://<registereimageprovidername>/image.png"

        May be it is hitting issue because of this.

        L Offline
        L Offline
        literA2
        wrote on last edited by
        #3

        @dheerendra said in ERROR: Failed to get image from provider:

        If you are using the imageProvide you need to used the syntax like
        "image://<registereimageprovidername>/image.png"

        May be it is hitting issue because of this.

        Thanks for the reply.

        But yes, i am using such syntax, that is why it is working fine.

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          Your program looks ok. Which image is shown ? image1.png or image2.png ?. I suspect that you should be seeing imag1.png & image2.png is not shown. Is that correct ? I'm sure one of the image is not present with your imageProvider.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          L 1 Reply Last reply
          6
          • dheerendraD dheerendra

            Your program looks ok. Which image is shown ? image1.png or image2.png ?. I suspect that you should be seeing imag1.png & image2.png is not shown. Is that correct ? I'm sure one of the image is not present with your imageProvider.

            L Offline
            L Offline
            literA2
            wrote on last edited by
            #5

            @dheerendra said in ERROR: Failed to get image from provider:

            Your program looks ok. Which image is shown ? image1.png or image2.png ?. I suspect that you should be seeing imag1.png & image2.png is not shown. Is that correct ? I'm sure one of the image is not present with your imageProvider.

            I updated my first post. The "image2.png" can be null if it can't be found from the settings file.

            1 Reply Last reply
            0
            • dheerendraD Offline
              dheerendraD Offline
              dheerendra
              Qt Champions 2022
              wrote on last edited by dheerendra
              #6

              I guess This issue is coming from image2.png which you are loading in oncompleted signal and image2.png is not in your image provider

              Dheerendra
              @Community Service
              Certified Qt Specialist
              http://www.pthinks.com

              1 Reply Last reply
              6
              • M Offline
                M Offline
                MaxL
                wrote on last edited by
                #7

                My guess here is that you will always get an error message if you try to load a null image.
                However you could workaround it by returning image1 from your QuickImageProvider if you find out there that image2 is null

                your code would only be something like:

                QML side:
                
                Image {
                  source: "image:://provide/image2.png"
                }
                
                Cpp side:
                
                // Here it depends on your provider  and it is very simplified
                QImage requestImage( const QString &id, QSize *size, const QSize &requestedSize )
                {
                    QImage img = get( id ); 
                    if( img.isNull() )
                    {
                        // You can log here if you want
                        qDebug() << "Image with id" << id << "is null, defaulting to image1";
                        return img.get( idImage1 );
                    }
                    return img;
                }
                
                

                Hope this helps

                L 1 Reply Last reply
                1
                • M MaxL

                  My guess here is that you will always get an error message if you try to load a null image.
                  However you could workaround it by returning image1 from your QuickImageProvider if you find out there that image2 is null

                  your code would only be something like:

                  QML side:
                  
                  Image {
                    source: "image:://provide/image2.png"
                  }
                  
                  Cpp side:
                  
                  // Here it depends on your provider  and it is very simplified
                  QImage requestImage( const QString &id, QSize *size, const QSize &requestedSize )
                  {
                      QImage img = get( id ); 
                      if( img.isNull() )
                      {
                          // You can log here if you want
                          qDebug() << "Image with id" << id << "is null, defaulting to image1";
                          return img.get( idImage1 );
                      }
                      return img;
                  }
                  
                  

                  Hope this helps

                  L Offline
                  L Offline
                  literA2
                  wrote on last edited by
                  #8

                  @MaxL Thank you for your reply. This is what I did, instead of my original approach to handle it in QML.

                  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