<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 29 May 2022 at 16:31, ivan tkachenko <<a href="mailto:me@ratijas.tk">me@ratijas.tk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I have a problem which sounds like it should be something trivial.<br>
<br>
I got a QIcon icon, aquired from a model by a delegate. How do i use it in <br>
controls with all these <a href="http://icon.name" rel="noreferrer" target="_blank">icon.name</a> [string], icon.source [url] groupped <br>
properties or even with just an Image type?<br>
<br>
All sane attempts failed. I'm left with this a decade-old StackOverflow answer <br>
to use custom Image Provider. Sounds like too much work for something that <br>
should be just here, out of the box?<br></blockquote><div><br></div><div>A QIcon is a collection of images.<br>A QQuickIcon is just a struct containing a URL plus some options (width, height, etc.).<br><br>Internally to render the icon, the QQuickIcon's URL is just forwarded to a QQuickIconImage which will attempt to retrieve the image from the URL.<br>So there is no easy way to feed a QIcon to a QQuickIcon as you must use a URL at some point.<br><br>The standard solution is to use a QQuickImageProvider.<br>In C++ you would implement your own QQuickImageProvider which will contain the QIcons.<br>In QML then you would use a url like "image://myprovider/icon_id".<br>Then the QML engine will call your QQuickImageProvider to retrieve the icon image.<br><br>An alternative solution might be to use data urls, but I have never tried it.<br><br>BR<br><br>Benjamin<br> </div></div></div>