在本页

MapItemView QML Type

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

Import Statement: import QtLocation 6.11
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

该属性包含定义如何显示模型中每个项目的委托。组件的根对象必须正好包含一个 MapItem 派生对象。

delegateModelAccess : enumeration [since 6.10]

该属性决定了代表如何访问模型。

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

默认值为DelegateModel.Qt5ReadWrite

此属性在 Qt 6.10 中引入。

另请参阅 Qt Quick#更改模型数据中的模型和视图

model : model

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

remove : Transition [since QtLocation 5.12]

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

该属性在 QtLocation 5.12 中引入。

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