2014-02-14 30 views
0

我是bb 10應用程序開發中的新手。我正在嘗試閱讀此聯繫人的詳細信息,我可以讀取名字和姓氏(任何類型的單一數據類型值)。但在QList價值的情況下,我無法找到價值。BB 10:無法讀取級聯編程中的contact.phonenumbers()值

這裏是我的代碼:

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"; 
} 

回答

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; 
      } 
     } 
    } 
+0

嗨,@Kanak索尼感謝答覆。我嘗試這個代碼,但它不能進入​​如果情況。手段phoneno_list來了一個空的,但我的設備有一些與它的數字聯繫。 –