- Qt 6.12
- Qt Graphs
- QML Types
- QtGraphs
- ItemModelBarDataProxy
- Qt Graphs | Commercial or GPLv3

# ItemModelBarDataProxy QML Type

Proxy class for presenting data in item models with Bars3D. More...

Import Statement: | `import QtGraphs`
In C++: | QItemModelBarDataProxy
Inherits: | BarDataProxy

- List of all members, including inherited members
- ItemModelBarDataProxy is part of Qt Graphs QML Types for 3D.

## Properties

- autoColumnCategories : bool
- autoRowCategories : bool
- columnCategories : list<String>
- columnRole : string
- columnRolePattern : regExp
- columnRoleReplace : string
- itemModel : model
- multiMatchBehavior : enumeration
- rotationRole : string
- rotationRolePattern : regExp
- rotationRoleReplace : string
- rowCategories : list<String>
- rowRole : string
- rowRolePattern : regExp
- rowRoleReplace : string
- type : AbstractDataProxy.DataType
- useModelCategories : bool
- valueRole : string
- valueRolePattern : regExp
- valueRoleReplace : string

## Signals

- autoColumnCategoriesChanged(bool enable)
- autoRowCategoriesChanged(bool enable)
- columnCategoriesChanged()
- columnRoleChanged(string role)
- columnRolePatternChanged(regExp pattern)
- columnRoleReplaceChanged(string replace)
- itemModelChanged(model itemModel)
- multiMatchBehaviorChanged(enumeration behavior)
- rotationRoleChanged(string role)
- rotationRolePatternChanged(regExp pattern)
- rotationRoleReplaceChanged(string replace)
- rowCategoriesChanged()
- rowRoleChanged(string role)
- rowRolePatternChanged(regExp pattern)
- rowRoleReplaceChanged(string replace)
- useModelCategoriesChanged(bool enable)
- valueRoleChanged(string role)
- valueRolePatternChanged(regExp pattern)
- valueRoleReplaceChanged(string replace)

## Detailed Description

This type allows you to use AbstractItemModel derived models as a data source for Bars3D.

Data is resolved asynchronously whenever the mapping or the model changes. QBarDataProxy::arrayReset() is emitted when the data has been resolved.

For ItemModelBarDataProxy enums, see QItemModelBarDataProxy::MultiMatchBehavior.

For more details, see QItemModelBarDataProxy documentation.

Usage example:

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

See also BarDataProxy and Qt Graphs Data Handling with 3D.

## Property Documentation

### autoColumnCategories : bool

When set to `true`, the mapping ignores any explicitly set column categories and overwrites them with automatically generated ones whenever the data from model is resolved. Defaults to `true`.

### autoRowCategories : bool

When set to `true`, the mapping ignores any explicitly set row categories and overwrites them with automatically generated ones whenever the data from the model is resolved. Defaults to `true`.

### columnCategories : list<String>

The column categories of the mapping. Only items with column role values that are found in this list are included when the data is resolved. The columns are ordered in the same order as they are in this list.

### columnRole : string

The item model role to map into column category.

### columnRolePattern : regExp

When set, a search and replace is done on the value mapped by column role before it is used as a column category. This property specifies the regular expression to find the portion of the mapped value to replace and columnRoleReplace property contains the replacement string. This is useful for example in parsing row and column categories from a single timestamp field in the item model.

See also columnRole and columnRoleReplace.

### columnRoleReplace : string

This property defines the replacement content to be used in conjunction with columnRolePattern. Defaults to empty string. For more information on how the search and replace using regular expressions works, see QString::replace(const QRegularExpression &rx, const QString &after) function documentation.

See also columnRole and columnRolePattern.

### itemModel : model

The item model.

### multiMatchBehavior : enumeration

Defines how multiple matches for each row/column combination are handled. Defaults to ItemModelBarDataProxy.MultiMatchBehavior.Last. The chosen behavior affects both bar value and rotation.

For example, you might have an item model with timestamped data taken at irregular intervals and you want to visualize total value of data items on each day with a bar graph. This can be done by specifying row and column categories so that each bar represents a day, and setting multiMatchBehavior to ItemModelBarDataProxy.MultiMatchBehavior.Cumulative.

### rotationRole : string

The item model role to map into bar rotation angle.

### rotationRolePattern : regExp

When set, a search and replace is done on the value mapped by rotation role before it is used as a bar rotation angle. This property specifies the regular expression to find the portion of the mapped value to replace and rotationRoleReplace property contains the replacement string.

See also rotationRole and rotationRoleReplace.

### rotationRoleReplace : string

This property defines the replacement content to be used in conjunction with rotationRolePattern. Defaults to empty string. For more information on how the search and replace using regular expressions works, see QString::replace(const QRegularExpression &rx, const QString &after) function documentation.

See also rotationRole and rotationRolePattern.

### rowCategories : list<String>

The row categories of the mapping. Only items with row role values that are found in this list are included when the data is resolved. The rows are ordered in the same order as they are in this list.

### rowRole : string

The item model role to map into row category.

### rowRolePattern : regExp

When set, a search and replace is done on the value mapped by row role before it is used as a row category. This property specifies the regular expression to find the portion of the mapped value to replace and rowRoleReplace property contains the replacement string. This is useful for example in parsing row and column categories from a single timestamp field in the item model.

See also rowRole and rowRoleReplace.

### rowRoleReplace : string

This property defines the replacement content to be used in conjunction with rowRolePattern. Defaults to empty string. For more information on how the search and replace using regular expressions works, see QString::replace(const QRegularExpression &rx, const QString &after) function documentation.

See also rowRole and rowRolePattern.

### type : AbstractDataProxy.DataType `[read-only]`

The type of the proxy. One of the QAbstractDataProxy::DataType values.

### useModelCategories : bool

When set to `true`, the mapping ignores row and column roles and categories, and uses the rows and columns from the model instead. Row and column headers are used for row and column labels. Defaults to `false`.

### valueRole : string

The item model role to map into bar value.

### valueRolePattern : regExp

When set, a search and replace is done on the value mapped by value role before it is used as a bar value. This property specifies the regular expression to find the portion of the mapped value to replace and valueRoleReplace property contains the replacement string.

See also valueRole and valueRoleReplace.

### valueRoleReplace : string

This property defines the replacement content to be used in conjunction with valueRolePattern. Defaults to empty string. For more information on how the search and replace using regular expressions works, see QString::replace(const QRegularExpression &rx, const QString &after) function documentation.

See also valueRole and valueRolePattern.

## Signal Documentation

### autoColumnCategoriesChanged(bool enable)

This signal is emitted when autoColumnCategories changes to enable.

Note: The corresponding handler is `onAutoColumnCategoriesChanged`.

### autoRowCategoriesChanged(bool enable)

This signal is emitted when autoRowCategories changes to enable.

Note: The corresponding handler is `onAutoRowCategoriesChanged`.

### columnCategoriesChanged()

This signal is emitted when columnCategories changes.

Note: The corresponding handler is `onColumnCategoriesChanged`.

### columnRoleChanged(string role)

This signal is emitted when columnRole changes to role.

Note: The corresponding handler is `onColumnRoleChanged`.

### columnRolePatternChanged(regExp pattern)

This signal is emitted when columnRolePattern changes to pattern.

Note: The corresponding handler is `onColumnRolePatternChanged`.

### columnRoleReplaceChanged(string replace)

This signal is emitted when columnRoleReplace changes to replace.

Note: The corresponding handler is `onColumnRoleReplaceChanged`.

### itemModelChanged(model itemModel)

This signal is emitted when itemModel changes to itemModel.

Note: The corresponding handler is `onItemModelChanged`.

### multiMatchBehaviorChanged(enumeration behavior)

This signal is emitted when multiMatchBehavior changes to behavior.

Note: The corresponding handler is `onMultiMatchBehaviorChanged`.

### rotationRoleChanged(string role)

This signal is emitted when rotationRole changes to role.

Note: The corresponding handler is `onRotationRoleChanged`.

### rotationRolePatternChanged(regExp pattern)

This signal is emitted when rotationRolePattern changes to pattern.

Note: The corresponding handler is `onRotationRolePatternChanged`.

### rotationRoleReplaceChanged(string replace)

This signal is emitted when rotationRoleReplace changes to replace.

Note: The corresponding handler is `onRotationRoleReplaceChanged`.

### rowCategoriesChanged()

This signal is emitted when rowCategories changes.

Note: The corresponding handler is `onRowCategoriesChanged`.

### rowRoleChanged(string role)

This signal is emitted when rowRole changes to role.

Note: The corresponding handler is `onRowRoleChanged`.

### rowRolePatternChanged(regExp pattern)

This signal is emitted when rowRolePattern changes to pattern.

Note: The corresponding handler is `onRowRolePatternChanged`.

### rowRoleReplaceChanged(string replace)

This signal is emitted when rowRoleReplace changes to replace.

Note: The corresponding handler is `onRowRoleReplaceChanged`.

### useModelCategoriesChanged(bool enable)

This signal is emitted when useModelCategories changes to enable.

Note: The corresponding handler is `onUseModelCategoriesChanged`.

### valueRoleChanged(string role)

This signal is emitted when valueRole changes to role.

Note: The corresponding handler is `onValueRoleChanged`.

### valueRolePatternChanged(regExp pattern)

This signal is emitted when valueRolePattern changes to pattern.

Note: The corresponding handler is `onValueRolePatternChanged`.

### valueRoleReplaceChanged(string replace)

This signal is emitted when valueRoleReplace changes to replace.

Note: The corresponding handler is `onValueRoleReplaceChanged`.