Nominate our 2022 Qt Champions!

QQuickImageProvider for RichText <img src=image://imageprovider ...>

  • Dear Qt community,

    In Qt 5.15.1 I would like to represent an image within a text component using a QQuickImageProvider as follows

    Text {
        textFormat: Text.RichText
        text: "This is a red box: <img src='image://colors/red' width='60' height='60'>"

    As long as the textFormat equals Text.StyledText everything works fine.
    But as soon as the textFormat changes to Text.RichText the values for width and height are not passed to the image provider's requestImage() method anymore: requestedSize:(-1,-1)

    Is there a way to pass the requested image dimensions to the image provider?

  • @Witzgy A workaround could be to pass the size through the url, something like image://colors/red?width=60&height=60, and in the provider obtain the size of the "id".

Log in to reply