Revision as of 18:24, 13 December 2011 by kiran10182 (Talk | contribs)

Display SIM contacts using QML ContactModel

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Nokia C6-01
Device(s): Symbian
Platform Security
Capabilities: NetworkServices ReadUserData WriteUserData
Keywords: ContactModel
Created: Devnull (13 Dec 2011)
Last edited: kiran10182 (13 Dec 2011)



This article shows how to use QML ContactModel Element which is a part of the Qt Mobility Project and displays SIM contacts on the screen. This example uses Contacts QML Plugin from the QtMobility QML Plugins.


Qt SDK version 1.1.4 or later. Create an new Qt Quick application.

Project File (.pro file)

  • Add the Qt Mobility project configuration option in the .Pro file as shown below
CONFIG += mobility
MOBILITY += contacts
  • here is the project(.pro) file part related to Symbian capabilities.
symbian {
TARGET.CAPABILITY = NetworkServices ReadUserData WriteUserData

Qml file

Here is the MainPage.qml.

import QtQuick 1.1
import com.nokia.symbian 1.1
import QtMobility.contacts 1.1
Page {
id: mainPage
Text {
id: title
text: "Contacts"
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 6
color: platformStyle.colorNormalLight
ListView {
id: mainList
anchors.left: parent.left
anchors.leftMargin: 3
anchors.right: parent.right
anchors.rightMargin: 3
anchors.top: title.bottom
anchors.bottom: parent.bottom
anchors.topMargin: 3
cacheBuffer: 100
clip: true
highlightFollowsCurrentItem: true
snapMode: ListView.SnapOneItem
model: contactModel.contacts
delegate: listDelegate
ContactModel {
id: contactModel
manager: "symbiansim" // "symbian" for other contact manager
autoUpdate :true
SortOrder {
detail: ContactDetail.Name
field: Name.LastName
direction: Qt.AscendingOrder
Component {
id: listDelegate
ListItem {
id: contactItem
subItemIndicator: true
ListItemText {
id: nameItem
mode: contactItem.mode
role: "Title"
text: displayLabel
ScrollDecorator {
flickableItem: mainList
128 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.