×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    95

    Question 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
    Code:
    QmlApplicationViewer viewer;
        QDeclarativeEngine * engine = viewer.engine();
        engine->addImageProvider(QLatin1String("thumbnail"), new ContactsImageProvider);
    //QML delegate file
    Code:
    Image {
            id: personPhoto
    
            height: 75
            width: 75
            source: "image://thumbnail/" + contactId
            anchors.left: parent.left
        }
    //ContactsImageProvider
    Code:
    ContactsImageProvider::ContactsImageProvider()
        :QDeclarativeImageProvider(QDeclarativeImageProvider::Image)
    {
        m_contactsManager = new QContactManager;
    }
    
    ContactsImageProvider::~ContactsImageProvider()
    {
        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();
        if(!thumbnail.isNull())
        {
            return thumbnail;
        }
        return QImage();
    }
    I always got the following error
    QML Image: Failed to get image from provider
    is there a solution?

  2. #2
    Super Contributor
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,037

    Re: QML Image: Failed to get image from provider

    you can try to set the property from qt like:

    QObject *rootObject = dynamic_cast<QObject*>(mDeclarativeView->rootObject());
    QObject *personPhoto= rootObject->findChild<QObject *>("personPhoto");
    QDeclarativeProperty property(personPhoto, "source");
    property.write(path);

Similar Threads

  1. Wrap text around image with proper margin between image and text in QML?
    By pasi.hytonen@starcut.com in forum [Archived] Qt Quick
    Replies: 0
    Last Post: 2011-03-31, 07:58
  2. How to get image path from image gallary
    By bnpawar in forum Symbian
    Replies: 6
    Last Post: 2010-11-26, 07:48
  3. Failed to get image from camera - N95
    By prchakal in forum Symbian
    Replies: 2
    Last Post: 2010-05-22, 06:14
  4. How to get informations about an image without creating the Image Object
    By cristi.mota in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2008-06-27, 08:47
  5. Moving Focus from one image to other image.
    By crazystar in forum Mobile Java General
    Replies: 3
    Last Post: 2007-09-25, 11:37

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •