本页内容

MapItemView QML Type

MapItemView 用于从模型中为 Map 填充数据。更多内容...

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

QtObject

属性

详细说明

MapItemView 用于将模型中的 MapItems 填充到 Map 中。MapItemView 类型仅在作为 Map 的组成部分时才有意义,这意味着它不具备独立的展示形式。

使用示例

本示例演示了如何使用 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.