Important: Please read the Qt Code of Conduct -

[Solved]Reading all contacts from mobile using QML Mobility Plugins.

  • Hi all, I need to retrieve the list of contacts from my mobile phone to show it in a ListView. But I can't do it using the example provided in the QML Mobility Plugins Document. I've tried so many times and failed. I can successfully display all the messages using the QML Mobility Plugins example, but I can't do it for the ContactModel. The documentation also did not help me much. Can anybody please provide a simple snippet for retrieving all the contacts and show it in a ListView.

    I tried to did it with Qt Mobility backend, but it produces unwanted error messages and I want my code to be clean. So please help me.

  • Moderators

    [quote author="raja26" date="1314530811"]I tried to did it with Qt Mobility backend, but it produces unwanted error messages and I want my code to be clean. So please help me.[/quote]

    What types of error messages did you get? If you share them, it may help someone point you in the right direction.

  • Actually they are not errors, but like warnings I'm using the same method for setting the model for my Contacts ListView "Example":

    But before setting the "model" property (using bound Variable), using context.setContextProperty() the QML shows warning that the "Can't find variable 'myModel'". This is shown only in the Qt Creator Application output pane. I think these errors will not affect my real application, but I still wanted my code to be clean.

  • Hi,

    I'm not really sure what you tried to do, but the code below is able to get the contact list using contact model and list view, on Simulator, on a Symbian device and on N9/N950 in plain QML. (If you are on Windows, in order for this to work on Qt Simulator you need to add the path to the QtMobility libraries to the PATH environment variable in the Project settings page).

    @import QtQuick 1.0
    import QtMobility.contacts 1.1

    Rectangle {
    width: 320
    height: 640

    //List view get's the ContactModel as a parameter, and can now show the contacts using e.g. a simple text delegate
    ListView {
        id:  contactList
        anchors.fill: parent
        model: ContactModel {}
        delegate: Text {
            text: "Name: " + + " " + + " Number: " +


  • Hi Tero Äijälä, Thank you for helping me. This was the actual code I was looking for.

    Update: Actually that code was working in Simulator and not on my Nokia E63 S60V3 FP1 mobile. So I updated the ListView with Qt Mobility (not QML Mobility plugins) Contacts API and updates the ListView.

  • Trying to run this on Nokia N8 via CODA. Getting this:

    @Thread has crashed: A data abort exception has occurred accessing 0x0.
    Process has finished.@

    Wonder what might be wrong.

  • Oh, I was just missing ReadUserData capability from the .pro file. Works ok now.

Log in to reply