在本页

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"]
}

另请参阅 BarDataProxyQt Graphs 3D 数据处理

属性文档

autoColumnCategories : bool

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

autoRowCategories : bool

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

columnCategories : list<String>

映射的列类别。在解析数据时,只有列角色值在此列表中的项目才会包含在内。列的顺序与此列表中的顺序相同。

columnRole : string

要映射到列类别中的项目模型角色。

columnRolePattern : regExp

如果设置了该属性,则在将列角色映射的值用作列类别之前,会对其进行搜索和替换。该属性指定正则表达式,用于查找要替换的映射值部分,而columnRoleReplace 属性则包含替换字符串。例如,在从条目模型中的单个时间戳字段解析行和列类别时,这就非常有用。

另请参阅 columnRolecolumnRoleReplace

columnRoleReplace : string

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

另请参阅 columnRolecolumnRolePattern

itemModel : model

项目模式。

multiMatchBehavior : enumeration

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

例如,您可能有一个带有时间戳数据的项目模型,这些数据是以不规则的时间间隔采集的,您希望用条形图来直观显示每天数据项的总价值。为此,您可以指定行和列的类别,使每个条形图代表一天,并将 multiMatchBehavior 设置为ItemModelBarDataProxy.MultiMatchBehavior.Cumulative

rotationRole : string

将项目模型角色映射到条形旋转角度。

rotationRolePattern : regExp

设置后,将对旋转角色映射的值进行搜索和替换,然后再将其用作条形图旋转角度。该属性指定正则表达式,用于查找要替换的映射值部分,而rotationRoleReplace 属性则包含替换字符串。

另请参阅 rotationRolerotationRoleReplace

rotationRoleReplace : string

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

另请参阅 rotationRolerotationRolePattern

rowCategories : list<String>

映射的行类别。在解析数据时,只包含此列表中具有行角色值的项目。行的排序顺序与此列表中的顺序相同。

rowRole : string

要映射到行类别中的项目模型角色。

rowRolePattern : regExp

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

另请参阅 rowRolerowRoleReplace

rowRoleReplace : string

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

另请参阅 rowRolerowRolePattern

type : AbstractDataProxy.DataType [read-only]

代理类型。QAbstractDataProxy::DataType 值之一。

useModelCategories : bool

当设置为true 时,映射会忽略行和列的角色和类别,而使用模型中的行和列。行和列标题用于行和列标签。默认设置为false

valueRole : string

要映射到条形图值中的项目模型角色。

valueRolePattern : regExp

设置该属性后,在将值用作条形图值之前,将对值角色映射的值进行搜索和替换。该属性指定正则表达式,用于查找要替换的映射值部分,而valueRoleReplace 属性则包含替换字符串。

另请参阅 valueRolevalueRoleReplace

valueRoleReplace : string

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

另请参阅 valueRolevalueRolePattern

信号文档

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.