ExtendedAttributes QML Type
ExtendedAttributes 类型存储有关“Place ”的附加数据。更多内容...
| Import Statement: | import QtLocation 6.12 |
| Since: | QtLocation 5.5 |
| In C++: | QQmlPropertyMap |
信号
- void valueChanged(string key, variant value)
方法
- variant keys()
详细说明
ExtendedAttributes 类型是一个placeAttributes 的映射。要访问映射中的属性,请使用keys() 方法获取映射中存储的键列表,并使用[] 运算符访问placeAttribute 项。
以下是 API 定义的标准键。Plugin 的实现可以自由定义其他键。自定义键应通过唯一的前缀进行限定,以避免冲突。
| key | 描述 |
|---|---|
| openingHours | 该场所的营业时间 |
| payment | 该场所接受的支付方式,例如Visa、万事达卡。 |
| x_provider | 该场所的供应商名称 |
| x_id_<provider>(例如 x_id_here) | 从指定提供商的角度识别该场所的替代标识符。 |
某些插件可能完全不支持属性,有些可能只支持特定的一组属性,还有些可能支持随时间动态变化的属性集,甚至允许客户端应用程序任意定义属性。属性也可能因地点而异,例如一个地点可能有营业时间,而另一个则没有。 详情请参阅插件参考文档。
某些属性可能不打算供最终用户阅读,此类属性的标签字段为空以表明这一事实。
注意:ExtendedAttributes 实例仅在Place的上下文中使用。无法直接创建ExtendedAttributes实例,也无法重新赋值Place 的ExtendedAttributes属性。对ExtendedAttributes的修改只能通过JavaScript实现。
以下示例演示了如何访问所有placeAttributes 并将它们打印到控制台:
import QtPositioning
import QtLocation
function printExtendedAttributes(extendedAttributes) {
var keys = extendedAttributes.keys();
for (var i = 0; i < keys.length; ++i) {
var key = keys[i];
if (extendedAttributes[key].label !== "")
console.log(extendedAttributes[key].label + ": " + extendedAttributes[key].text);
}
}以下示例演示了如何设置和修改属性:
//assign a new attribute to a place
var smokingAttrib = Qt.createQmlObject('import QtLocation; PlaceAttribute {}', place);
smokingAttrib.label = "Smoking Allowed"
smokingAttrib.text = "No"
place.extendedAttributes.smoking = smokingAttrib;
//modify an existing attribute
place.extendedAttributes.smoking.text = "Yes"另请参阅 placeAttribute 和QQmlPropertyMap 。
Signal 文档
void valueChanged(string key, variant value)
当属性集发生变化时,会触发此信号。key 是与被修改的value 对应的键。
相应的处理程序为onValueChanged 。
注意: 相应的处理程序 是onValueChanged 。
方法文档
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.