ERROR: Failed to get image from provider
-
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"; } }
-
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 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.
-
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 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.
-
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
-
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 nullyour 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