Re: [Interest] QIcon vs QQuickIcon

2022-06-14 Thread Remy Rouvin
What about passing the image in base64 format in the source property ?

-Message d'origine-
De : Interest  De la part de ivan tkachenko
Envoyé : mercredi 1 juin 2022 01:08
À : Benjamin TERRIER 
Cc : Qt Interest 
Objet : Re: [Interest] QIcon vs QQuickIcon

> The standard solution is to use a QQuickImageProvider.
> In C++ you would implement your own QQuickImageProvider which will 
> contain the QIcons.
> In QML then you would use a url like "image://myprovider/icon_id".
> Then the QML engine will call your QQuickImageProvider to retrieve the 
> icon image.
> 
> An alternative solution might be to use data urls, but I have never 
> tried it.

Sounds insanely complex when just got a QIcon from somewhere and you want to
feed it into UI.

Well, thanks for clarifying that no [easy] solution is currently available
in the Qt itself.

--
ivan (@ratijas)

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] QIcon vs QQuickIcon

2022-05-31 Thread ivan tkachenko
> The standard solution is to use a QQuickImageProvider.
> In C++ you would implement your own QQuickImageProvider which will contain
> the QIcons.
> In QML then you would use a url like "image://myprovider/icon_id".
> Then the QML engine will call your QQuickImageProvider to retrieve the icon
> image.
> 
> An alternative solution might be to use data urls, but I have never tried
> it.

Sounds insanely complex when just got a QIcon from somewhere and you want to 
feed it into UI.

Well, thanks for clarifying that no [easy] solution is currently available in 
the Qt itself.

-- 
ivan (@ratijas)

signature.asc
Description: This is a digitally signed message part.
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] QIcon vs QQuickIcon

2022-05-31 Thread Benjamin TERRIER
On Sun, 29 May 2022 at 16:31, ivan tkachenko  wrote:

> Hi,
>
> 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?
>

A QIcon is a collection of images.
A QQuickIcon is just a struct containing a URL plus some options (width,
height, etc.).

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.
So there is no easy way to feed a QIcon to a QQuickIcon as you must use a
URL at some point.

The standard solution is to use a QQuickImageProvider.
In C++ you would implement your own QQuickImageProvider which will contain
the QIcons.
In QML then you would use a url like "image://myprovider/icon_id".
Then the QML engine will call your QQuickImageProvider to retrieve the icon
image.

An alternative solution might be to use data urls, but I have never tried
it.

BR

Benjamin
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] QIcon vs QQuickIcon

2022-05-29 Thread EXT Mitch Curtis
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  on behalf of ivan tkachenko 

Date: Sunday, 29 May 2022 at 22:33
To: interest@qt-project.org 
Subject: [Interest] QIcon vs QQuickIcon
Hi,

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)
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest