tags:

views:

28

answers:

1

i use this code and getting contact details of only one person ....

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();

output:

Name: andrew Number: +7811341255

but i want list of contact like this

Name: andrew Number: +7811341255
Name: person2 Number: +44124156
Name: person3 Number: +212113

....list of no of contact in phone what can i do ..please help me....

+1  A: 

If you want to print all of them, you should iterate over the QList returned by QContactManager::contacts().

This should get you started (I'll just whip it up for you):

// 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

http://doc.qt.nokia.com/4.5/qlist-iterator.html

http://www.cppreference.com/wiki/stl/iterators

Nubsis