ExtendedAttributes QML Type

扩展属性(ExtendedAttributes)类型保存有关Place 的附加数据... 更多...

Import Statement: import QtLocation 6.9
Since: QtLocation 5.5
In C++: QQmlPropertyMap

信号

方法

详细说明

ExtendedAttributes 类型是placeAttributes 的映射。要访问映射中的属性,可使用keys() 方法获取映射中存储的键列表,并使用[] 操作符访问placeAttribute 项。

以下是 API 定义的标准键。Plugin 实现可自由定义其他键。自定义键应使用唯一前缀限定,以避免冲突。

描述
营业时间场所的交易时间
付款方式该场所接受的付款方式,如签证、万事达卡。
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"

另请参阅 placeAttributeQQmlPropertyMap

信号文档

void valueChanged(string key, variant value)

该信号在属性集发生变化时发出。key 是与发生变化的value 相对应的键。

相应的处理程序是onValueChanged

注: 相应的处理程序是onValueChanged


方法文档

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.