Namespaces
Variants
Actions
Revision as of 10:35, 26 July 2011 by hamishwillee (Talk | contribs)

Add contact with image using Qt Mobility API

Jump to: navigation, search
Article Metadata

Tested with
Devices(s): Nokia N97 Mini

Compatibility
Platform(s): S60 5th Edition

Article
Keywords: QContactManager, QContact
Created: skumar_rao (27 Mar 2010)
Last edited: hamishwillee (26 Jul 2011)

Contents

Overview

This article shows you how to add contact to device PhoneBook with an image 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

// Following line will include "qtcontacts.h" file into the application.
 
#include "qtcontacts.h"
 
private:
QContactManager *contactManager;

Source File

// createing new instance of QContactManager
 
contactManager = new QContactManager("symbian");
    bool AddContact::createContact(QString firstName, QString secondName, QString mobileNumber, QString image) {
QContact contact;
 
QContactName name;
name.setFirstName(firstName);
name.setLastName(secondName);
contact.saveDetail(&name);
contactManager->synthesizeContactDisplayLabel(&contact);
 
QContactPhoneNumber phone;
phone.setContexts(QContactDetail::ContextHome);
phone.setSubTypes(QContactPhoneNumber::SubTypeMobile);
phone.setNumber(mobileNumber);
contact.saveDetail(&phone);
 
QContactAvatar avatar;
avatar.setImageUrl(image);
contact.saveDetail(&avatar);
 
return contactManager->saveContact(&contact);
}

Classes

  • QContactManager
  • QContact*

Reference links

228 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved