[Interest] QIcon vs QQuickIcon

EXT Mitch Curtis mitch.curtis at qt.io
Mon May 30 06:18:46 CEST 2022

As QIcon isn’t a gadget, you will probably need to make model roles for name and source and assign those to the QQuickIcon’s properties instead.

From: Interest <interest-bounces at qt-project.org> on behalf of ivan tkachenko <me at ratijas.tk>
Date: Sunday, 29 May 2022 at 22:33
To: interest at qt-project.org <interest at qt-project.org>
Subject: [Interest] QIcon vs QQuickIcon

I have a problem which sounds like it should be something trivial.

I got a QIcon icon, aquired from a model by a delegate. How do i use it in
controls with all these icon.name [string], icon.source [url] groupped
properties or even with just an Image type?

All sane attempts failed. I'm left with this a decade-old StackOverflow answer
to use custom Image Provider. Sounds like too much work for something that
should be just here, out of the box?

    icon: model.decoration
    // file:///usr/share/plasma/plasmoids/org.kde.desktopcontainment/contents/
ui/ConfigLocation.qml:115:21: Unable to assign QIcon to QQuickIcon
    // no conversion from QIcon to this gadget type

    icon.name: model.decoration.name
    icon.source: model.decoration.source
    // ConfigLocation.qml:116:21: Unable to assign [undefined] to QUrl
    // ConfigLocation.qml:115:21: Unable to assign [undefined] to QString
    // probably because QIcon doesn't have introspectible meta-properties?

ivan (@ratijas)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20220530/7e18a63b/attachment.htm>

More information about the Interest mailing list