ContactDetails QML Type (Uncreatable)
ContactDetails 型は、Place の連絡先情報を保持します。詳細...
| Import Statement: | import QtLocation 6.12 |
| Since: | QtLocation 5.5 |
注:これは作成不可能な型です。QML内ではインスタンス化できません。
メソッド
- variant keys()
詳細な説明
ContactDetails型は、contactDetail オブジェクトのマップです。マップ内の連絡先詳細にアクセスするには、keys()メソッドを使用してマップに格納されているキーのリストを取得し、その後、[] 演算子を使用してcontactDetail の項目にアクセスします。
API では以下のキーが定義されています。Plugin の実装では、追加のキーを自由に定義することができます。
- phone
- fax
- website
ContactDetails インスタンスは、Places のコンテキスト内でのみ使用されます。ContactDetails インスタンスを直接作成したり、ContactDetails インスタンスをPlaces に再割り当てしたりすることはできません。ContactDetails の変更は、Javascript を通じてのみ行うことができます。
例
以下の例は、すべての `contact details ` にアクセスし、それらをコンソールに出力する方法を示しています:
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);
}
}
}返される連絡先情報のリストはオブジェクトのリストであるため、データモデルとして直接使用できます。たとえば、以下は連絡先の電話番号のリストをリストビューに表示する方法を示しています:
import QtQuick
import QtPositioning
import QtLocation
ListView {
model: place.contactDetails.phone;
delegate: Text { text: modelData.label + ": " + modelData.value }
}次の例は、JavaScriptで場所に1つの電話番号を割り当てる方法を示しています:
function writeSingle() {
var phoneNumber = Qt.createQmlObject('import QtLocation; ContactDetail {}', place);
phoneNumber.label = "Phone";
phoneNumber.value = "555-5555"
place.contactDetails.phone = phoneNumber;
}以下は、JavaScriptで1つの場所に複数の電話番号を割り当てる方法を示しています:
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;
}メソッドのドキュメント
variant keys()
マップに現在格納されている連絡先の詳細キーの配列を返します。
© 2026 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.