ContactDetails QML Type
ContactDetails型は、Place の連絡先の詳細を保持します。
Import Statement: | import QtLocation 6.8 |
Since: | QtLocation 5.5 |
メソッド
- variant keys()
詳細説明
ContactDetails型は、contactDetail オブジェクトのマップです。マップ内の連絡先の詳細にアクセスするには、keys() メソッドを使用してマップに格納されているキーのリストを取得し、[]
演算子を使用してcontactDetail 項目にアクセスします。
以下のキーがAPIで定義されています。Plugin 実装は、追加のキーを自由に定義できます。
- 電話
- fax
- 電子メール
- ウェブサイト
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つの電話番号を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() |
現在マップに保存されている連絡先詳細キーの配列を返します。
© 2025 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.