placeAttribute QML Value Type

placeAttribute 类型用于保存通用的地点属性信息。更多

Import Statement: import QtLocation 6.9
Since: QtLocation 5.5

属性

详细说明

地点属性存储了关于Place 的附加信息,这些信息无法通过Place 类型公开。placeAttribute 是一段文本数据,可通过text 属性和label 访问。l {placeAttribute::}{text} 和label 属性都是为了显示给用户看。placeAttribute 存储在一个具有唯一键的ExtendedAttributes 地图中。

下面的示例展示了如何在列表中显示所有属性:

import QtQuick
import QtPositioning
import QtLocation

ListView {
    model: place.extendedAttributes.keys()
    delegate: Text {
        text: "<b>" + place.extendedAttributes[modelData].label + ": </b>" +
              place.extendedAttributes[modelData].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"

属性文档

label : string

该属性包含属性标签,它是用户可见的描述属性的字符串。


text : string

属性文本 该属性包含属性文本,可用于显示有关地点的附加信息。


© 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.