Add contact with image using Qt Mobility API
hamishwillee
(Talk | contribs) m (Hamishwillee - Addition to article of: Category:MeeGo Category:Symbian. (Add platform categories)) |
hamishwillee
(Talk | contribs) m (Text replace - "<code cpp>" to "<code cpp-qt>") |
||
| (One intermediate revision by one user not shown) | |||
| Line 22: | Line 22: | ||
* 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 cpp> | + | <code cpp-qt> |
CONFIG += mobility | CONFIG += mobility | ||
MOBILITY += contacts | MOBILITY += contacts | ||
| Line 28: | Line 28: | ||
== Header File == | == Header File == | ||
| − | <code cpp> | + | <code cpp-qt> |
// Following line will include "qtcontacts.h" file into the application. | // Following line will include "qtcontacts.h" file into the application. | ||
| Line 38: | Line 38: | ||
== Source File == | == Source File == | ||
| − | <code cpp> | + | <code cpp-qt> |
// createing new instance of QContactManager | // 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) { | ||
| Line 76: | Line 76: | ||
* [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/qt-roadmap New Qt APIs Beta - Mobility Project] | * [http://qt.nokia.com/developer/qt-roadmap New Qt APIs Beta - Mobility Project] | ||
| − | * SDK help[[Category:MeeGo]] [[Category:Symbian]] | + | * 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*

