ContactDetails QML Type

The ContactDetails type holds contact details for a Place. More...

Import Statement: import QtLocation 5.3
Since: Qt Location 5.5


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.


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

import QtPositioning 5.5
import QtLocation 5.6

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:

import QtQuick 2.0
import QtPositioning 5.5
import QtLocation 5.6

ListView {
    delegate: Text { text: modelData.label + ": " + modelData.value }

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

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

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

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

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

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

Method Documentation

variant keys()

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

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.