我是bb 10 app开发的新手。我正在尝试阅读联系方式,我可以读取名字和姓氏(任何类型的单一数据类型值)。但是在QList
值的情况下,我无法找到价值。
这是我的代码:
foreach(Contact le, contactList ){
out << "Name: "<< le.displayName()<<","<<le.firstName()<<" "<<le.lastName()<<"\n";
out << "No: ";
const QList<ContactAttribute> noAttributes = le.phoneNumbers();
foreach (const ContactAttribute &noAttribute, noAttributes) {
out<< "in";
out<< noAttribute.value();
}
out<<"\n";
}
答案 0 :(得分:1)
试试这个 -
// getting phone numbers
QVariantMap map_contact;
QList<ContactAttribute> phoneno_list = contact_info.phoneNumbers();
if(!phoneno_list.isEmpty())
{
foreach(ContactAttribute attr, phoneno_list)
{
switch (attr.subKind()) {
case AttributeSubKind::PhoneMobile:
map_contact["phonemobile"] = attr.value();
break;
case AttributeSubKind::Home:
map_contact["phonehome"] = attr.value();
break;
case AttributeSubKind::Work:
map_contact["phonework"] = attr.value();
break;
default:
map_contact["phone"]= attr.value();
break;
}
}
}