本页内容

CategoryModel QML Type

CategoryModel 类型提供了一个模型,用于表示Plugin 所支持的分类。更多内容...

Import Statement: import QtLocation 6.12
Since: QtLocation 5.5

属性

信号

方法

详细说明

CategoryModel 类型提供了当前Plugin 网站中可用分类的模型。该模型既支持分类的扁平列表,也支持表示分类分组的层次结构树。这可以通过hierarchical 属性进行控制。

该模型支持以下角色:

角色类型描述
categoryCategory当前项的类别对象。
父类别Category当前项目的父类别对象。如果没有父类别,则返回 null。

以下示例显示了所有可用类别的扁平列表:

import QtQuick
import QtPositioning
import QtLocation

ListView {
    model: CategoryModel {
        plugin: myPlugin
        hierarchical: false
    }
    delegate: Text { text: category.name }
}

要访问分层分类模型,必须使用DelegateModel 来访问子项。

属性文档

hierarchical : bool

无论模型提供的是分类的层级树还是扁平列表,此属性均有效。默认值为 true。

plugin : Plugin

该属性存储了该模型所使用的提供程序Plugin 。

status : enumeration [read-only]

该属性保存模型的状态。其取值可以是以下之一:

CategoryModel.Null尚未执行任何类别获取查询。该模型为空。
CategoryModel.Ready上次操作未发生错误,可对该模型执行后续操作。
CategoryModel.Loading模型正在更新,更新完成前无法执行其他操作。
CategoryModel.错误上一次操作中发生了错误,但仍可对模型执行后续操作。

信号文档

dataChanged()

当底层数据存储发生重大变化时,会发出此信号。

应用程序应自行决定如何处理此信号。模型提供的数据可能已过时,因此模型应在适当时候重新更新;但如果分类发生变化而用户未采取任何操作,立即重新更新可能会让用户感到困惑。

相应的处理程序是onDataChanged 。

注意: 相应的处理程序 是onDataChanged 。

方法文档

string errorString()

此只读属性存储最新类别模型错误的文本表示形式。如果未发生错误,则返回空字符串。

如果发生的错误没有关联的文本表示,则也会返回一个空字符串。

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