Results 1 to 2 of 2

Thread: QML Image: Failed to get image from provider

  1. #1
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default QML Image: Failed to get image from provider

    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?

  2. #2
    Join Date
    Dec 2012
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: QML Image: Failed to get image from provider

    may be id ==-1? when item is invisible.

Similar Threads

  1. Release program failed to show jpg image on another PC!
    By bangqianchen in forum Qt Programming
    Replies: 4
    Last Post: 31st January 2010, 22:16
  2. Replies: 6
    Last Post: 21st September 2009, 10:55
  3. Saving image in jpeg format failed
    By febil in forum Qt Programming
    Replies: 5
    Last Post: 23rd April 2009, 11:33
  4. hide image,once moused moved from image
    By yuvaraj.yadav in forum Qt Programming
    Replies: 1
    Last Post: 22nd April 2009, 08:16
  5. Replies: 3
    Last Post: 14th March 2007, 08:09

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.