Add contact with image using Qt Mobility API
m |
hamishwillee
(Talk | contribs) m (Text replace - "<code cpp>" to "<code cpp-qt>") |
||
| (7 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
| − | [[Category:Qt | + | [[Category:Qt Mobility]] |
| − | {| | + | {{ArticleMetaData |
| − | + | |sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] --> | |
| − | | | + | |installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) --> |
| − | + | |devices=Nokia N97 Mini | |
| − | + | |sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) --> | |
| − | | | + | |platform=S60 5th Edition |
| − | + | |devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) --> | |
| − | |- | + | |signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer --> |
| − | + | |capabilities=<!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. --> | |
| − | + | |keywords=QContactManager, QContact | |
| − | + | |id= <!-- Article Id (Knowledge base articles only) --> | |
| − | | | + | |creationdate=27th Mar 2010 |
| − | + | |author=[[User:Skumar rao|Skumar rao]] | |
| − | + | }} | |
| − | + | ||
| − | |- | + | |
| − | | | + | |
| − | | | + | |
| − | + | ||
| − | + | ||
== Overview == | == 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 | ||
| − | + | <code cpp-qt> | |
| − | + | ||
| − | <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> |
| + | // createing new instance of QContactManager | ||
| + | |||
contactManager = new QContactManager("symbian"); | contactManager = new QContactManager("symbian"); | ||
</code> | </code> | ||
| − | <code cpp> | + | <code cpp-qt> |
bool AddContact::createContact(QString firstName, QString secondName, QString mobileNumber, QString image) { | bool AddContact::createContact(QString firstName, QString secondName, QString mobileNumber, QString image) { | ||
| − | QContact | + | QContact contact; |
| − | + | ||
| − | + | ||
| − | + | ||
| − | name. | + | QContactName name; |
| − | + | name.setFirstName(firstName); | |
| − | name. | + | 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 | + | QContactAvatar avatar; |
| − | + | avatar.setImageUrl(image); | |
| − | + | contact.saveDetail(&avatar); | |
| − | + | ||
| − | + | ||
| − | return contactManager->saveContact(& | + | return contactManager->saveContact(&contact); |
} | } | ||
</code> | </code> | ||
| Line 80: | 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/ | + | * [http://qt.nokia.com/developer/qt-roadmap New Qt APIs Beta - Mobility Project] |
| − | * SDK help | + | * SDK help[[Category:MeeGo Harmattan]] [[Category:Symbian]] |
| − | + | ||
Latest revision as of 04:23, 11 October 2012
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
(11 Oct 2012)
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*

