IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

ContactDetails QML Type

The ContactDetails type holds contact details for a Place.

This type was introduced in QtLocation 5.5.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

ContactDetails QML Type

  • Import Statement: import QtLocation 6.5

  • Since:: QtLocation 5.5

  • Group: ContactDetails is part of qml-QtLocation5-places, qml-QtLocation5-places-data

I. Detailed Description

The ContactDetails type is a map of contactDetail objects. To access contact details in the map use the keys() method to get the list of keys stored in the map and then use the [] operator to access the contactDetail items.

The following keys are defined in the API. Plugin implementations are free to define additional keys.

  • phone

  • fax

  • email

  • website

ContactDetails instances are only ever used in the context of Places. It is not possible to create a ContactDetails instance directly or re-assign ContactDetails instances to Places. Modification of ContactDetails can only be accomplished via Javascript.

I-1. Examples

The following example shows how to access all contact details and print them to the console:

 
Sélectionnez
import QtPositioning
import QtLocation

function printContactDetails(contactDetails) {
    var keys = contactDetails.keys();
    for (var i = 0; i < keys.length; ++i) {
        var contactList = contactDetails[keys[i]];
        for (var j = 0; j < contactList.length; ++j) {
            console.log(contactList[j].label + ": " + contactList[j].value);
        }
    }
}

The returned list of contact details is an object list and so can be used directly as a data model. For example, the following demonstrates how to display a list of contact phone numbers in a list view:

 
Sélectionnez
import QtQuick
import QtPositioning
import QtLocation

ListView {
    model: place.contactDetails.phone;
    delegate: Text { text: modelData.label + ": " + modelData.value }
}

The following example demonstrates how to assign a single phone number to a place in JavaScript:

 
Sélectionnez
function writeSingle() {
    var phoneNumber = Qt.createQmlObject('import QtLocation; ContactDetail {}', place);
    phoneNumber.label = "Phone";
    phoneNumber.value = "555-5555"
    place.contactDetails.phone = phoneNumber;
}

The following demonstrates how to assign multiple phone numbers to a place in JavaScript:

 
Sélectionnez
function writeMultiple() {
    var bob = Qt.createQmlObject('import QtLocation; ContactDetail {}', place);
    bob.label = "Bob";
    bob.value = "555-5555"

    var alice = Qt.createQmlObject('import QtLocation; ContactDetail {}', place);
    alice.label = "Alice";
    alice.value = "555-8745"

    var numbers = new Array();
    numbers.push(bob);
    numbers.push(alice);

    place.contactDetails.phone = numbers;
}

II. Method Documentation

 

II-1. variant keys()

Returns an array of contact detail keys currently stored in the map.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+