For reasons I don’t know, apparantly a Qt Quick Item that can show a QImage or a QPixmap is kind of missing. The current Image QML item only works with data that can be represented by a URL.
So I wrote one that kind of works. Comments most welcome.
It is found on git.kde.org: http://quickgit.kde.org/?p=scratch/sune/imageitem.git
Oh, and the KDE End of Year fundraiser is still running. https://www.kde.org/fundraisers/yearend2014/. Go support it if you haven’t already.
Umm. lets not reinvent wheel, http://quickgit.kde.org/?p=kdeclarative.git&a=tree&h=4695f15012da340071b2fd1d164d48b994eff04c&hb=4c53cd514ed4202fb7d98a1c67943e313072d7aa&f=src%2Fqmlcontrols%2Fkquickcontrolsaddons
Oh. I wasn’t even aware that I was reinventing a sharable wheel. I asked around if such a thing existed, and no one knew. But apparantly I didn’t look enough and asked the right people.
Anyways. It was also a interesting learning experience.
Granted not as straight forward, but I think one can use QImage or QPixmap with the Image element through a QQuickImageProvider
Kevin: How do you pass the QImage/QPixmap into the QQuickImageProvider ? I tried it, but only base64 encoded data in QString was the way that looked possible
What about using the standard Image { }, but with a C++ method that converts QImage/QPixmap into an URI :
“data:image/png;base64,”
It just works !
But then I would need to encode it to png format and then have the QML engine decode it again. Isn’t that a bit .. double?
One advantage of the URL approach over setting plain images is that with URLs you can support high-dpi setups with automatic loading of @2x, etc. images.