Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [Solved]Reading all contacts from mobile using QML Mobility Plugins.
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Mobile and Embedded
7 Posts 4 Posters 3.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    raja26
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      [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.

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        raja26
        wrote on last edited by
        #3

        Actually they are not errors, but like warnings I'm using the same method for setting the model for my Contacts ListView "Example":http://doc.qt.nokia.com/4.7-snapshot/declarative-modelviews-objectlistmodel-main-cpp.html.

        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.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          teroa
          wrote on last edited by
          #4

          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: " + model.contact.name.firstName + " " + model.contact.name.lastName + " Number: " + model.contact.phoneNumber.number
              }
          
          }
          

          }
          @

          1 Reply Last reply
          0
          • R Offline
            R Offline
            raja26
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              strekazoid
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                strekazoid
                wrote on last edited by
                #7

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

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved