placeAttribute QML Value Type
placeAttribute 类型用于存储通用位置属性信息。更多内容...
| Import Statement: | import QtLocation 6.12 |
| Since: | QtLocation 5.5 |
属性
详细说明
“place”属性用于存储有关Place 的额外信息,这些信息无法通过Place 类型直接获取。 placeAttribute 是一段文本数据,可通过text 属性访问,并属于label 类型。l {placeAttribute::}{text} 和label 这两个属性均旨在向用户显示。placeAttributes 存储在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
该属性包含“text”字段,可用于显示有关该地点的更多信息。
© 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.