Hi everybody,

I have a problem when importing images from C++ into QML
QML Image: Failed to get image from provider
//main.cpp
Qt Code:
  1. QmlApplicationViewer viewer;
  2. QDeclarativeEngine * engine = viewer.engine();
  3. engine->addImageProvider(QLatin1String("thumbnail"), new ContactsImageProvider);
To copy to clipboard, switch view to plain text mode 

//QML delegate file
Qt Code:
  1. Image {
  2. id: personPhoto
  3.  
  4. height: 75
  5. width: 75
  6. source: "image://thumbnail/" + contactId
  7. anchors.left: parent.left
  8. }
To copy to clipboard, switch view to plain text mode 

//ContactsImageProvider
Qt Code:
  1. ContactsImageProvider::ContactsImageProvider()
  2. :QDeclarativeImageProvider(QDeclarativeImageProvider::Image)
  3. {
  4. m_contactsManager = new QContactManager;
  5. }
  6.  
  7. ContactsImageProvider::~ContactsImageProvider()
  8. {
  9. delete m_contactsManager;
  10. }
  11.  
  12. QImage ContactsImageProvider::requestImage(const QString& id, QSize* size, const QSize& requestedSize)
  13. {
  14. QContact contact = m_contactsManager->contact(id.toUInt());
  15. QContactThumbnail thumb = contact.detail(QContactThumbnail::DefinitionName);
  16. QImage thumbnail = thumb.thumbnail();
  17. if(!thumbnail.isNull())
  18. {
  19. return thumbnail;
  20. }
  21. return QImage();
  22. }
To copy to clipboard, switch view to plain text mode 

I always got the following error
QML Image: Failed to get image from provider
is there a solution?