MapItemView QML Type

MapItemView 用于从模型中填充地图。更多

Import Statement: import QtLocation 6.10
Since: QtLocation 5.5
Inherits:

QtObject

属性

详细说明

MapItemView 用于用模型中的 MapItems 填充地图。MapItemView 类型只有在包含在地图中时才有意义,这意味着它没有独立的表现形式。

使用示例

本例演示了如何使用 MapViewItem 对象在map 上显示route

import QtQuick
import QtPositioning
import QtLocation

Map {
    RouteModel {
        id: routeModel
    }

    MapItemView {
        model: routeModel
        delegate: routeDelegate
    }

    Component {
        id: routeDelegate

        MapRoute {
            route: routeData
            line.color: "blue"
            line.width: 5
            smooth: true
            opacity: 0.8
        }
    }
}

属性文档

add : Transition [since QtLocation 5.12]

该属性用于保存视图创建的地图项在实例化并添加到地图时所应用的转换。

该属性在 QtLocation 5.12 中引入。


autoFitViewport : bool

该属性控制在添加或删除项目时是否自动平移和缩放视口以显示所有地图项目。

默认为 false。


delegate : Component

该属性持有定义如何显示模型中每个项的委托。该组件必须包含一个地图项目派生对象作为根对象。


delegateModelAccess : enumeration [since 6.10]

该属性决定委托如何访问模型。

常量说明
DelegateModel.ReadOnly禁止代表通过上下文属性、model 对象或必填属性写入模型。
DelegateModel.ReadWrite允许代表通过上下文属性、model 对象或必填属性写入模型。
DelegateModel.Qt5ReadWrite允许代表通过model 对象和上下文属性写入模型,但不允许通过必填属性写入模型。

默认值为DelegateModel.Qt5ReadWrite

此属性在 Qt 6.10 中引入。

另请参阅 Qt Quick#ChangingModel Data(更改模型数据)中的 Models and Views(模型和视图)


model : model

该属性包含提供数据的模型,这些数据用于创建由委托定义的地图项。仅支持基于QAbstractItemModel 的模型。


remove : Transition [since QtLocation 5.12]

该属性保存视图创建的地图项被移除时所应用的转换。

该属性在 QtLocation 5.12 中引入。


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