×
Namespaces

Variants
Actions
(Difference between revisions)

如何在Qt中删除联系人

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Add link to original article)
hamishwillee (Talk | contribs)
m (Text replace - "<code cpp>" to "<code cpp-qt>")
 
(4 intermediate revisions by one user not shown)
Line 1: Line 1:
[[Category:Qt]][[Category:Qt Mobility]][[Category:Code Examples]][[Category:Code Snippet]][[Category:Lang-Chinese]]
+
[[Category:Qt]][[Category:Qt Mobility]][[Category:Code Snippet]][[Category:Code Snippet]][[Category:Lang-Chinese]]
{{ArticleMetaData
+
{{ArticleMetaData <!-- v1.2 -->
 
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 
|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]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
Line 7: Line 7:
 
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->  
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
|signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
+
|signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
|capabilities=<!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
+
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
|id= <!-- Article Id (Knowledge base articles only) -->
+
|language= Lang-Chinese
|language=Lang-Chinese
+
|translated-by= [[User:Hoolee]]
|translated-by= <!-- [[User: XXXXX]] -->
+
|translated-from-title= Removing contact in Qt
|translated-from-title=<!-- Title only -->
+
|translated-from-id= 74922 <!-- automated guess -->
|translated-from-id= <!-- Id of translated revision -->
+
|review-by= <!-- After re-review: [[User:username]] -->
|review-by=<!-- After re-review: [[User:username]] -->
+
|review-timestamp= <!-- After re-review: YYYYMMDD -->
|review-timestamp=<!-- After re-review: YYYYMMDD -->
+
|update-by= <!-- After significant update: [[User:username]]-->
|update-by=<!-- After significant update: [[User:username]]-->
+
|update-timestamp= <!-- After significant update: YYYYMMDD -->
|update-timestamp=<!-- After significant update: YYYYMMDD -->
+
|creationdate= 20100528
|creationdate=20100528
+
|author= [[User:Tepaa]]
|author=[[User:Hoolee]]
+
 
}}
 
}}
  
Original: [[CS001623 - Removing contact in Qt]]
 
  
 
==概述==
 
==概述==
Line 32: Line 30:
 
==Qt工程文件==
 
==Qt工程文件==
  
<code cpp>
+
<code cpp-qt>
 
CONFIG += mobility
 
CONFIG += mobility
 
MOBILITY = contacts
 
MOBILITY = contacts
 
</code>
 
</code>
  
<code cpp>
+
<code cpp-qt>
 
symbian {
 
symbian {
 
TARGET.CAPABILITY = ReadUserData WriteUserData
 
TARGET.CAPABILITY = ReadUserData WriteUserData
Line 45: Line 43:
 
==头文件==
 
==头文件==
  
<code cpp>
+
<code cpp-qt>
 
// QtMobility
 
// QtMobility
 
#include <qcontactmanager.h>
 
#include <qcontactmanager.h>
Line 56: Line 54:
 
==源文件==
 
==源文件==
  
<code cpp>
+
<code cpp-qt>
 
// Create manager (Symbian backend)
 
// Create manager (Symbian backend)
 
QContactManager contactManager("symbian");
 
QContactManager contactManager("symbian");
Line 96: Line 94:
  
 
==相关参考==
 
==相关参考==
* [[Setting_up_Qt_Mobility]]
+
* [[Setting up Qt Mobility]]
* http://doc.qt.nokia.com/qtmobility-1.0/contacts.html
+
* http://doc.qt.nokia.com/qtmobility-1.0/contacts.html[[Category:MeeGo Harmattan]] [[Category:Symbian]]
 +
<!-- Translation --> [[en:Removing contact in Qt]]

Latest revision as of 04:19, 11 October 2012

Article Metadata

兼容于
平台:
Symbian

文章
翻译:
hoolee
最后由 hamishwillee 在 11 Oct 2012 编辑


Contents

[edit] 概述

下列代码片段演示了如何使用Qt Mobility的联系人模块来删除联系人数据

[edit] Qt工程文件

CONFIG += mobility
MOBILITY = contacts
symbian {
TARGET.CAPABILITY = ReadUserData WriteUserData
}

[edit] 头文件

// QtMobility
#include <qcontactmanager.h>
#include <qcontact.h>
#include <qcontactdetailfilter.h>
#include <qcontactphonenumber.h>
QTM_USE_NAMESPACE

[edit] 源文件

// Create manager (Symbian backend)
QContactManager contactManager("symbian");
 
// Search contact by phone number
QContact contact;
// Filter for search
QContactDetailFilter phoneFilter;
phoneFilter.setDetailDefinitionName(QContactPhoneNumber::DefinitionName,
QContactPhoneNumber::SubTypeMobile);
phoneFilter.setValue("0503654295");
phoneFilter.setMatchFlags(QContactFilter::MatchPhoneNumber);
 
// Find contacts
QList<QContact> matchingContacts = contactManager.contacts(phoneFilter);
if (matchingContacts.size() != 0) {
contact = matchingContacts.at(0);
}
 
// Remove contact
if (!contact.isEmpty()) {
if (QMessageBox::Yes == QMessageBox::question(this,"Contact",
QString("Do you want to remove contact: %1").arg(contact.displayLabel()),
QMessageBox::Yes|QMessageBox::No)) {
 
bool ret = contactManager.removeContact(contact.localId());
if (!ret) {
QMessageBox::information(this, "Failed!",
QString("Failed to remove contact!\n(error code %1)")
.arg(contactManager.error()));
}
}
}

[edit] 后记

联系人成功删除

[edit] 相关参考

This page was last modified on 11 October 2012, at 04:19.
212 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.

×