[Qt-qml] Image { pixmap } is gone :( Can't use QIcons anymore
bea.lam at nokia.com
bea.lam at nokia.com
Fri Jul 23 04:48:46 CEST 2010
Hi Steve,
On 22/07/2010, at 1:03 AM, ext Stephen Kelly wrote:
> Hello,
>
> The pixmap property has been removed.
>
> http://bugreports.qt.nokia.com/browse/QTBUG-11980
>
> This came as a great surprise to us because we are using it and it is
> already very late in the release cycle to be removing things like that. The
> replacement
>
> http://doc.trolltech.com/main-snapshot/qdeclarativeimageprovider.html
>
> Does not satisfy our usecase because it assumes that all you have in qml is
> a name of a pixmap you want, not the actual image.
How does your model assign the QIcon for each pixmap? If it is loaded from a file name, or has some other identifying name, you can add a new role for the model (e.g. "imageSource") and then assign this name as a value, with a prefix as necessary according to your custom image provider's name (e.g. "image://myimageprovider/the_icon_name"). Add the new role using QAbstractItemModel::setRoleNames(), and then in your QML you can replace
> Image {
> id: collectionIcon
> pixmap: KDE.iconToPixmap( model.decoration, height );
> width: 48; height: 48
> }
with
Image {
...
source: imageSource
}
The relevant part of the imageSource string (e.g. "my_icon_name") will be passed to your QDeclarativeImageProvider::requestPixmap() method as the "id" string, so the requestPixmap() implementation can create a QIcon and return a pixmap using KDE.iconToPixmap() as before (or perhaps just load the pixmap without QIcon).
The provider can be registered with the QML engine that provides your view e.g. if using QDeclarativeView:
view.engine()->addImageProvider("myimageprovider", new KDEIntegrationImageProvider);
regards,
Bea
More information about the Qt-qml
mailing list