Read all contacts from device phonebook using Qt Mobility API

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Created: skumar_rao (16 Mar 2010)
Last edited: hamishwillee (11 Oct 2012)
ID Creation date 15th Mar 2010
Platform S60 5th Edition Tested on devices Nokia N97 Mini
Category Qt Subcategory Qt Mobility API

Keywords (APIs, classes, methods, functions): QContactManager, QContactDetail

This article shows how to read all contacts from device PhoneBook using Qt Mobility API


Project configuration file (.Pro file)

  • Add the Qt Mobility project configuration option in the .Pro file as shown below
CONFIG += mobility
MOBILITY += contacts

Header File

#include <QContactManager>
/* All QtMobility api's are part of QtMobility namespace. */
using namespace QtMobility;

Source File

void phonebook_manager::readall()
QStringList availableManagers = QContactManager::availableManagers();
for(int managerIdx = 0; managerIdx < availableManagers.count(); managerIdx++) {
QContactManager *manager = new QContactManager(availableManagers.at(managerIdx));
if(manager) {
QList<QContactLocalId> contacts = manager->contacts();
for(int contactIdx =0; contactIdx < contacts.count(); contactIdx++) {
QContact contact = manager->contact(contacts.at(contactIdx));
QString label =contact.displayLabel(); // display label of contact
QList<QContactDetail> contactDetails = contact.details();
foreach (const QContactDetail& details, contactDetails) {
QList<QString> fieldKeys = details.values().keys();
foreach (const QString& key, fieldKeys) {
// key : give you the Field name
// details.value(key) : give you Field value
delete manager;


  • QContactManager
  • QContactDetail

Reference links

--skumar_rao 14:42, 16 March 2010 (UTC)

This page was last modified on 11 October 2012, at 04:18.
50 page views in the last 30 days.