×
Namespaces

Variants
Actions
(Difference between revisions)

Add contact with image using Qt Mobility API

From Nokia Developer Wiki
Jump to: navigation, search
vivainio (Talk | contribs)
(Overview)
hamishwillee (Talk | contribs)
m (Text replace - "<code cpp>" to "<code cpp-qt>")
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Category:Qt for Symbian]][[Category:Qt for Symbian]]
+
[[Category:Qt Mobility]]
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
{{ArticleMetaData
|-
+
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
|'''ID''' ||
+
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|'''Creation date''' || 27th Mar 2010
+
|devices=Nokia N97 Mini
|-
+
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|'''Platform''' || S60 5th Edition
+
|platform=S60 5th Edition
|'''Tested on devices''' || Nokia N97 Mini
+
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
|-
+
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
|'''Category''' || Qt for Symbian
+
|capabilities=<!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
|'''Subcategory''' || Qt Mobility API
+
|keywords=QContactManager, QContact  
|-
+
|id= <!-- Article Id (Knowledge base articles only) -->
|}
+
|creationdate=27th Mar 2010
 
+
|author=[[User:Skumar rao|Skumar rao]]
 
+
}}
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
|-
+
|'''Keywords (APIs, classes, methods, functions)''': QContactManager, QContact  
+
|}
+
 
+
{{Tip| Read this article before moving forward: [[Setting up environment for Qt Mobility API]]}}
+
  
 
== Overview ==  
 
== Overview ==  
Add contact to device PhoneBook with image using Qt Mobility API
 
  
'''Warning: API has been changed, please update this.'''
+
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
  
== Project configuration file (.Pro file) ==
+
<code cpp-qt>
* Add the Qt Mobility project configuration option in the .Pro file as shown below
+
<code>
+
 
CONFIG += mobility
 
CONFIG += mobility
 
MOBILITY += contacts
 
MOBILITY += contacts
Line 36: Line 28:
  
 
== Header File ==
 
== Header File ==
<code cpp>
+
<code cpp-qt>
 +
// Following line will include "qtcontacts.h" file into the application.
 +
 
 
#include "qtcontacts.h"
 
#include "qtcontacts.h"
  
Line 44: Line 38:
  
 
== Source File ==
 
== Source File ==
<code cpp>
+
<code cpp-qt>
contactManager = new QContactManager("symbian");
+
// createing new instance of QContactManager
 +
 
 +
  contactManager = new QContactManager("symbian");
 
</code>
 
</code>
<code cpp>
+
<code cpp-qt>
bool AddContact::createContact(QString firstName, QString secondName, QString mobileNumber, QString image) {
+
    QContact curr;
+
    QContactName name = curr.detail(QContactName::DefinitionName);
+
    QContactPhoneNumber phone = curr.detail(QContactPhoneNumber::DefinitionName);
+
    QContactAvatar avatar = curr.detail(QContactAvatar::DefinitionName);
+
  
     name.setFirst(firstName);
+
     bool AddContact::createContact(QString firstName, QString secondName, QString mobileNumber, QString image) {
 +
    QContact contact;
  
     name.setLast(secondName);
+
    QContactName name;
 +
     name.setFirstName(firstName);
 +
    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>
Line 79: Line 75:
 
* [http://qt.nokia.com/ Qt - cross-platform application and UI framework]
 
* [http://qt.nokia.com/ Qt - cross-platform application and UI framework]
 
* [http://labs.trolltech.com/page/Projects/QtMobility Qt Mobility API]
 
* [http://labs.trolltech.com/page/Projects/QtMobility Qt Mobility API]
* [http://qt.nokia.com/developer/new-qt-apis New Qt APIs Beta - Mobility Project]
+
* [http://qt.nokia.com/developer/qt-roadmap New Qt APIs Beta - Mobility Project]
* SDK help
+
* SDK help[[Category:MeeGo Harmattan]] [[Category:Symbian]]
--[[User:Skumar rao|Skumar rao]] 15:03, 27 March 2010 (UTC)
+

Latest revision as of 04:23, 11 October 2012

Article Metadata
Tested with
Devices(s): Nokia N97 Mini
Compatibility
Platform(s): S60 5th Edition
Symbian
Article
Keywords: QContactManager, QContact
Created: skumar_rao (27 Mar 2010)
Last edited: hamishwillee (11 Oct 2012)

Contents

[edit] Overview

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

[edit] Project configuration file (.Pro file)

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

[edit] Header File

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

[edit] 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);
}

[edit] Classes

  • QContactManager
  • QContact*

[edit] Reference links

This page was last modified on 11 October 2012, at 04:23.
62 page views in the last 30 days.
×