×
Namespaces

Variants
Actions
(Difference between revisions)

Add contact with image using Qt Mobility API

From Nokia Developer Wiki
Jump to: navigation, search
vasant21 (Talk | contribs)
m
olkonone (Talk | contribs)
(Updated to use QtMobility 1.1 API)
Line 1: Line 1:
[[Category:Qt for Symbian]]
+
[[Category:Portuguese]]
 
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"  
 
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"  
 
|-
 
|-
Line 23: Line 23:
 
== Overview ==  
 
== Overview ==  
 
Add contact to device PhoneBook with image using Qt Mobility API
 
Add contact to device PhoneBook with image using Qt Mobility API
 
'''Warning: API has been changed, please update this.'''
 
  
 
== Keywords ==
 
== Keywords ==
Line 50: Line 48:
  
 
     bool AddContact::createContact(QString firstName, QString secondName, QString mobileNumber, QString image) {
 
     bool AddContact::createContact(QString firstName, QString secondName, QString mobileNumber, QString image) {
     QContact curr;
+
     QContact contact;
    QContactName name = curr.detail(QContactName::DefinitionName);
+
    QContactPhoneNumber phone = curr.detail(QContactPhoneNumber::DefinitionName);
+
    QContactAvatar avatar = curr.detail(QContactAvatar::DefinitionName);
+
  
     name.setFirst(firstName);
+
    QContactName name;
 
+
     name.setFirstName(firstName);
     name.setLast(secondName);
+
     name.setLastName(secondName);
 +
    contact.saveDetail(&name);
 +
    contactManager->synthesizeContactDisplayLabel(&contact);
  
 +
    QContactPhoneNumber phone;
 
     phone.setContexts(QContactDetail::ContextHome);
 
     phone.setContexts(QContactDetail::ContextHome);
 
     phone.setSubTypes(QContactPhoneNumber::SubTypeMobile);
 
     phone.setSubTypes(QContactPhoneNumber::SubTypeMobile);
 
     phone.setNumber(mobileNumber);
 
     phone.setNumber(mobileNumber);
 +
    contact.saveDetail(&phone);
  
     avatar.setAvatar(image);
+
     QContactAvatar avatar;
 
+
     avatar.setImageUrl(image);
     curr.saveDetail(&name);
+
     contact.saveDetail(&avatar);
    curr.saveDetail(&phone);
+
     curr.saveDetail(&avatar);
+
  
     return contactManager->saveContact(&curr);
+
     return contactManager->saveContact(&contact);
 
     }
 
     }
 
</code>
 
</code>

Revision as of 11:07, 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

Add contact to device PhoneBook with 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

#include "qtcontacts.h"
 
private:
QContactManager *contactManager;

Source File

   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)

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

×