Ask / Submit

How to read an email address from a Person of PeopleModel?

asked 2019-02-24 19:06:52 +0200

jsommer gravatar image

updated 2019-02-24 19:08:20 +0200

The documentation of the nemo-qml-plugin-contacts suggests, that the emailDetails of a Person are returned as a QVariantList. Unfortunately I couldn't manage to get the email addresses. A similar challange is to get the phone numbers.

I have looked at the EmailEditor.qml and MultiTypeFieldEditor.qml of the default Sailfish email app. The value field of the QVariant object in the QVariantList seems to be "address", but I always get "undifiend" in the log. Here are some trials:

var contact = contacts.personById(contactIdentifier)
for (var emailDetails in contact.emailDetails) {
    console.log("- " + emailDetails['address'])
    console.log("- " + emailDetails.address)
    console.log("- " + emailDetails.value)
    console.log("- " + emailDetails.label)

The toString() method returns just the index of the QVariant object.

Has someone an idea?

edit retag flag offensive close delete

1 Answer

Sort by » oldest newest most voted

answered 2019-02-25 01:05:31 +0200

jsommer gravatar image

The solution was easy:

var contact = contacts.personById(contactIdentifier
var emailDetails = contact.emailDetails
for (var i = 0; i < emailDetails.length; i++) {
    console.log("Entry " + emailDetails[i].address)
edit flag offensive delete publish link more



@jsommer Could you please accept this answer and close the question as answered? By the way, thank you for sharing your programming problems and solutions here.

Maus ( 2019-02-25 11:16:05 +0200 )edit
Login/Signup to Answer

Question tools



Asked: 2019-02-24 19:06:52 +0200

Seen: 134 times

Last updated: Feb 25