×
Namespaces

Variants
Actions
(Difference between revisions)

Add contact with image using Qt Mobility API

From Nokia Developer Wiki
Jump to: navigation, search
olkonone (Talk | contribs)
(Updated to use QtMobility 1.1 API)
girishpadia (Talk | contribs)
Line 22: Line 22:
  
 
== Overview ==  
 
== Overview ==  
Add contact to device PhoneBook with image using Qt Mobility API
+
 
 +
This article shows you how to add contact to device PhoneBook with an image using Qt Mobility API
  
 
== Keywords ==
 
== Keywords ==
  
 
== Project configuration file (.Pro file) ==
 
== Project configuration file (.Pro file) ==
* Add the Qt Mobility project configuration option in the .Pro file as shown below
+
* Add the Qt Mobility project configuration option in the .pro file as shown below
<code>
+
 
 +
<code cpp>
 
CONFIG += mobility
 
CONFIG += mobility
 
MOBILITY += contacts
 
MOBILITY += contacts
Line 35: Line 37:
 
== Header File ==
 
== Header File ==
 
<code cpp>
 
<code cpp>
 +
// Following line will include "qtcontacts.h" file into the application.
 +
 
#include "qtcontacts.h"
 
#include "qtcontacts.h"
  
Line 43: Line 47:
 
== Source File ==
 
== Source File ==
 
<code cpp>
 
<code cpp>
 +
// createing new instance of QContactManager
 +
 
   contactManager = new QContactManager("symbian");
 
   contactManager = new QContactManager("symbian");
 
</code>
 
</code>

Revision as of 14:16, 22 March 2011

ID Creation date 27th Mar 2010
Platform S60 5th Edition Tested on devices Nokia N97 Mini
Category Qt for Symbian Subcategory Qt Mobility API


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

Tip.pngTip: Read this article before moving forward: Setting up environment for Qt Mobility API

Contents

Overview

This article shows you how to add contact to device PhoneBook with an image using Qt Mobility API

Keywords

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

--skumar_rao 15:03, 27 March 2010 (UTC)

99 page views in the last 30 days.
×