本页内容

ItemModelBarDataProxy QML Type

用于通过Bars3D 在项模型中呈现数据的代理类。更多内容...

Import Statement: import QtGraphs
In C++: QItemModelBarDataProxy
Inherits:

BarDataProxy

属性

信号

详细说明

此类允许您将继承自 AbstractItemModel 的模型用作Bars3D 的数据源。

每当映射或模型发生变化时,数据都会异步解析。当数据解析完成后,会触发QBarDataProxy::arrayReset() 事件。

有关 ItemModelBarDataProxy 枚举,请参阅QItemModelBarDataProxy::MultiMatchBehavior 。

有关更多详细信息,请参阅QItemModelBarDataProxy 文档。

使用示例:

ItemModelBarDataProxy {
    itemModel: model // E.g. a list model defined elsewhere containing yearly expenses data.
    // Mapping model roles to bar series rows, columns, and values.
    rowRole: "year"
    columnRole: "city"
    valueRole: "expenses"
    rowCategories: ["2020", "2021", "2022", "2023"]
    columnCategories: ["Oulu", "Rauma", "Helsinki", "Tampere"]
}

另请参阅 BarDataProxy 以及Qt Graphs 中的 3D 数据处理。

属性文档

autoColumnCategories : bool

当设置为true 时,映射会忽略任何显式设置的列类别,并在每次解析模型中的数据时,用自动生成的列类别覆盖它们。默认值为true 。

autoRowCategories : bool

当设置为true 时,映射会忽略任何显式设置的行类别,并在每次解析模型数据时,用自动生成的行类别覆盖它们。默认值为true 。

columnCategories : list<String>

映射的列类别。在解析数据时,仅包含列角色值出现在此列表中的项目。列的排序顺序与该列表中的顺序一致。

columnRole : string

用于映射到“列”类别的项目模型角色。

columnRolePattern : regExp

启用此属性后,在将由列角色映射的值用作列类别之前,会对其进行搜索和替换操作。该属性指定用于查找映射值中待替换部分的正则表达式,而columnRoleReplace 属性则包含替换字符串。例如,在从项目模型中的单个时间戳字段解析行和列类别时,此功能非常有用。

另请参阅 columnRole 和columnRoleReplace 。

columnRoleReplace : string

该属性定义了与columnRolePattern 配合使用的替换内容。默认值为空字符串。有关使用正则表达式进行搜索和替换的工作原理的更多信息,请参阅QString::replace (constQRegularExpression &rx, constQString &after)函数的文档。

另请参阅 columnRole 和columnRolePattern 。

itemModel : model

该商品的模型。

multiMatchBehavior : enumeration

定义了如何处理每个行/列组合中的多个匹配项。默认值为ItemModelBarDataProxy.MultiMatchBehavior.Last 。所选的行为会同时影响条形图的数值和旋转角度。

例如,假设您有一个包含不规则间隔采集的带时间戳数据的项模型,并希望通过条形图可视化每天数据项的总值。您可以通过指定行和列类别(使每个条形代表一天),并将 `multiMatchBehavior` 设置为 `ItemModelBarDataProxy.MultiMatchBehavior.Cumulative` 来实现这一点。

rotationRole : string

用于映射到条形旋转角度的项模型角色。

rotationRolePattern : regExp

启用此设置后,在将轮转角色映射的值用作条形轮转角度之前,会对其进行搜索和替换操作。该属性指定用于查找映射值中待替换部分的正则表达式,而rotationRoleReplace 属性则包含替换字符串。

另请参阅 rotationRole 和rotationRoleReplace 。

rotationRoleReplace : string

该属性定义了与rotationRolePattern 配合使用的替换内容。默认值为空字符串。有关使用正则表达式进行搜索和替换的工作原理的更多信息,请参阅QString::replace (constQRegularExpression &rx, constQString &after)函数文档。

另请参阅 rotationRole 和rotationRolePattern 。

rowCategories : list<String>

映射的行类别。在解析数据时,仅包含行角色值出现在此列表中的项目。行的排序顺序与该列表中的顺序一致。

rowRole : string

用于映射到行类别的项目模型角色。

rowRolePattern : regExp

启用此属性后,在将由行角色映射的值用作行类别之前,会对其进行搜索和替换操作。该属性指定用于查找映射值中待替换部分的正则表达式,而rowRoleReplace 属性则包含替换字符串。例如,在从项目模型中的单个时间戳字段解析行和列类别时,此功能非常有用。

另请参阅 rowRole 和rowRoleReplace 。

rowRoleReplace : string

该属性定义了与rowRolePattern 配合使用的替换内容。默认值为空字符串。有关使用正则表达式进行搜索和替换的工作原理的更多信息,请参阅QString::replace (constQRegularExpression &rx, constQString &after)函数文档。

另请参阅 rowRole 和rowRolePattern 。

type : AbstractDataProxy.DataType [read-only]

代理的类型。QAbstractDataProxy::DataType 中的某个值。

useModelCategories : bool

当设置为true 时,映射将忽略行和列的角色及类别,而是直接使用模型中的行和列。行和列标题将作为行和列的标签。默认值为false 。

valueRole : string

用于映射到条形图值的项目模型角色。

valueRolePattern : regExp

启用此属性后,在将映射值用作条形图值之前,会对其进行搜索和替换操作。该属性指定用于查找映射值中待替换部分的正则表达式,而valueRoleReplace 属性则包含替换字符串。

另请参阅 valueRole 和valueRoleReplace 。

valueRoleReplace : string

该属性定义了与valueRolePattern 配合使用的替换内容。默认值为空字符串。有关使用正则表达式进行搜索和替换的更多信息,请参阅QString::replace (constQRegularExpression &rx, constQString &after)函数的文档。

另请参阅 valueRole 和valueRolePattern 。

信号文档

autoColumnCategoriesChanged(bool enable)

当autoColumnCategories 变为enable 时,会触发此信号。

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

autoRowCategoriesChanged(bool enable)

当autoRowCategories 变为enable 时,会触发此信号。

注意: 相应的处理程序 为onAutoRowCategoriesChanged 。

columnCategoriesChanged()

当columnCategories 发生变化时,会触发此信号。

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

columnRoleChanged(string role)

当columnRole 变为role 时,会触发此信号。

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

columnRolePatternChanged(regExp pattern)

当columnRolePattern 变为pattern 时,会触发此信号。

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

columnRoleReplaceChanged(string replace)

当columnRoleReplace 变为replace 时,会触发此信号。

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

itemModelChanged(model itemModel)

当itemModel 变为itemModel 时,会触发此信号。

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

multiMatchBehaviorChanged(enumeration behavior)

当multiMatchBehavior 变为behavior 时,会触发此信号。

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

rotationRoleChanged(string role)

当rotationRole 变为role 时,会触发此信号。

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

rotationRolePatternChanged(regExp pattern)

当rotationRolePattern 变为pattern 时,会触发此信号。

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

rotationRoleReplaceChanged(string replace)

当rotationRoleReplace 变为replace 时,会触发此信号。

注意: 相应的处理程序 为onRotationRoleReplaceChanged 。

rowCategoriesChanged()

当rowCategories 发生变化时,会触发此信号。

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

rowRoleChanged(string role)

当rowRole 变为role 时,会触发此信号。

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

rowRolePatternChanged(regExp pattern)

当rowRolePattern 变为pattern 时,会触发此信号。

注意: 相应的处理程序 为onRowRolePatternChanged 。

rowRoleReplaceChanged(string replace)

当rowRoleReplace 变为replace 时,会发出此信号。

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

useModelCategoriesChanged(bool enable)

当useModelCategories 变为enable 时,会触发此信号。

注意: 相应的处理程序 为onUseModelCategoriesChanged 。

valueRoleChanged(string role)

当valueRole 变为role 时,会触发此信号。

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

valueRolePatternChanged(regExp pattern)

当valueRolePattern 变为pattern 时,会触发此信号。

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

valueRoleReplaceChanged(string replace)

当valueRoleReplace 变为replace 时,会触发此信号。

注意: 相应的处理程序 为onValueRoleReplaceChanged 。

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