QML update Image source with base64
-
wrote on 10 May 2021, 13:42 last edited by BruceLin 5 Oct 2021, 13:43
Should I create custom QML object from QML Image and what I should do after?
-
@BruceLin
most generic way would probably be to implement a custom QQuickImageProvider.
And for example then use it like this:Image format fixed/known:
Image { source: "image://mybase64/UG9seWZvbiB....." }
Image format dynamic (requires parsing in the image provider implementation for the mime type):
Image { source: "image://mybase64/data:image/png;base64,iVBORw0KGgoA......" }
To be honest i am unsure if Qt will just pass the last data url (with the second colon in the path) 1:1 to your implementation, simply give it a try.
-
@BruceLin
most generic way would probably be to implement a custom QQuickImageProvider.
And for example then use it like this:Image format fixed/known:
Image { source: "image://mybase64/UG9seWZvbiB....." }
Image format dynamic (requires parsing in the image provider implementation for the mime type):
Image { source: "image://mybase64/data:image/png;base64,iVBORw0KGgoA......" }
To be honest i am unsure if Qt will just pass the last data url (with the second colon in the path) 1:1 to your implementation, simply give it a try.
@raven-worx said in QML update Image source with base64:
Image { source: "image://mybase64/data:image/png;base64,iVBORw0KGgoA......" }
No need for a custom QQuickImageProvider. QML can decode data URLs!
Image { source: "data:image/png;base64,iVBORw0KGgoA......" }