View Full Version : QML Image: Failed to get image from provider

17th May 2011, 10:43
Hi everybody,

I have a problem when importing images from C++ into QML

QML Image: Failed to get image from provider


QmlApplicationViewer viewer;
QDeclarativeEngine * engine = viewer.engine();
engine->addImageProvider(QLatin1String("thumbnail"), new ContactsImageProvider);

//QML delegate file

Image {
id: personPhoto

height: 75
width: 75
source: "image://thumbnail/" + contactId
anchors.left: parent.left


:QDeclarativeImageProvider(QDeclarativeImageProvid er::Image)
m_contactsManager = new QContactManager;

delete m_contactsManager;

QImage ContactsImageProvider::requestImage(const QString& id, QSize* size, const QSize& requestedSize)
QContact contact = m_contactsManager->contact(id.toUInt());
QContactThumbnail thumb = contact.detail(QContactThumbnail::DefinitionName);
QImage thumbnail = thumb.thumbnail();
return thumbnail;
return QImage();

I always got the following error

QML Image: Failed to get image from provider
is there a solution?

13th December 2012, 15:37
may be id ==-1? when item is invisible.