CategoryModel QML Type

CategoryModel 类型为Plugin 支持的类别提供了一个模型 ... 更多...

Import Statement: import QtLocation 6.9
Since: QtLocation 5.5

属性

信号

方法

详细说明

CategoryModel 类型提供了当前Plugin 中可用类别的模型。该模型既支持类别的平面列表,也支持表示类别分组的分层树。这可由hierarchical 属性控制。

该模型支持以下角色:

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

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

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.就绪上次操作未发生错误,可对模型执行进一步操作。
CategoryModel.Loading模型正在更新,更新完成前不得执行其他操作。
CategoryModel.Error (错误上次操作过程中发生错误,仍可对模型执行其他操作。

信号文档

dataChanged()

当底层数据存储发生重大变更时会发出该信号。

应用程序应自行决定是否执行该信号。模型提供的数据可能已经过时,因此模型应适时重新更新,但如果在用户未采取任何行动的情况下改变了类别,则立即重新更新可能会让用户感到不安。

相应的处理程序是onDataChanged

注: 相应的处理程序是onDataChanged


方法文档

string errorString()

此只读属性包含最新类别模型错误的文字表述。如果没有发生错误,则返回空字符串。

如果发生的错误没有相关的文本表述,也会返回空字符串。


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