我使用此代码并获取只有一个人的联系方式....
contactManager = new QContactManager();
QList<QContact> contacts = contactManager->contacts();
contacts.detail(QContactPhoneNumber::DefinitionName).value(QContactPhoneNumber::FieldNumber);
QContact a = contactManager->contact(contacts.count());
QContactPhoneNumber no = a.detail<QContactPhoneNumber>();
qDebug() << "Name:" << a.displayLabel() << "Number:" << " " << no.number() ;
UserId = a.displayLabel();
PhoneNumber = no.number();
输出:
Name: andrew Number: +7811341255
但我想要这样的联系人列表
Name: andrew Number: +7811341255
Name: person2 Number: +44124156
Name: person3 Number: +212113
....电话中没有联系人的列表 任何帮助表示赞赏....
答案 0 :(得分:2)
如果您要打印所有这些内容,则应迭代QList
返回的QContactManager::contacts()
。
这应该让你开始(我只是为你鞭打):
// Contacts contains a list of ID:s
QList<QContactLocalId> contacts = contactManager->contacts();
// Now iterate
QList<QContactLocalId>::iterator it;
for (it = contacts.begin(); it != contacts.end(); ++it)
{
QContact contact = contactManager->contact(*it);
// And print contact information...
UserId name = contact.displayLabel();
PhoneNumber number = contact.number();
qDebug() << "Name: " << name
<< " Number: " << number << " ";
}
http://doc.qt.nokia.com/qtmobility-1.0-tp/qcontactmanager.html#contacts
http://doc.qt.nokia.com/4.5/qlist.html
答案 1 :(得分:1)
帮了我很多......谢谢......:)
只是一个修改:
QList<QContactLocalId> contacts = contactManager->contactsIds();
不
QList<QContactLocalId> contacts = contactManager->contacts();
答案 2 :(得分:0)
获取iOS&amp;的联系人列表Android,你也可以使用V-Play SDK。方法nativeUtils.getContacts()的工作方式如下:
import VPlayApps 1.0
App {
AppListView {
anchors.fill: parent
model: nativeUtils.getContacts()
delegate: SimpleRow {
text: modelData.name
detailText: modelData.phoneNumber
}
}
}