QItemModelScatterDataProxy Class | Qt Graphs | Qt 6.12.0
Description: Proxy class for presenting data in item models with Q3DScatterWidgetItem.
Keywords: class

- Qt 6.12
- Qt Graphs
- C++ Classes
- QtGraphs
- QItemModelScatterDataProxy
- Qt Graphs | Commercial or GPLv3

# QItemModelScatterDataProxy Class

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

Header: | `#include <QItemModelScatterDataProxy>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Graphs)` `target_link_libraries(mytarget PRIVATE Qt6::Graphs)`
qmake: | `QT += graphs`
In QML: | ItemModelScatterDataProxy
Inherits: | QScatterDataProxy

- List of all members, including inherited members
- QItemModelScatterDataProxy is part of Qt Graphs C++ Classes for 3D.

## Properties

itemModel : QAbstractItemModel* rotationRole : QString rotationRolePattern : QRegularExpression rotationRoleReplace : QString scaleRole : QString scaleRolePattern : QRegularExpression scaleRoleReplace : QString xPosRole : QString | xPosRolePattern : QRegularExpression xPosRoleReplace : QString yPosRole : QString yPosRolePattern : QRegularExpression yPosRoleReplace : QString zPosRole : QString zPosRolePattern : QRegularExpression zPosRoleReplace : QString

## Public Functions

| QItemModelScatterDataProxy(QObject *parent = nullptr)
| QItemModelScatterDataProxy(QAbstractItemModel *itemModel, QObject *parent = nullptr)
| QItemModelScatterDataProxy(QAbstractItemModel *itemModel, const QString &xPosRole, const QString &yPosRole, const QString &zPosRole, QObject *parent = nullptr)
| QItemModelScatterDataProxy(QAbstractItemModel *itemModel, const QString &xPosRole, const QString &yPosRole, const QString &zPosRole, const QString &rotationRole, QObject *parent = nullptr)
virtual | ~QItemModelScatterDataProxy() override
QAbstractItemModel * | itemModel() const
void | remap(const QString &xPosRole, const QString &yPosRole, const QString &zPosRole, const QString &rotationRole)
void | remap(const QString &xPosRole, const QString &yPosRole, const QString &zPosRole, const QString &rotationRole, const QString &scaleRole)
QString | rotationRole() const
QRegularExpression | rotationRolePattern() const
QString | rotationRoleReplace() const
QString | scaleRole() const
QRegularExpression | scaleRolePattern() const
QString | scaleRoleReplace() const
void | setItemModel(QAbstractItemModel *itemModel)
void | setRotationRole(const QString &role)
void | setRotationRolePattern(const QRegularExpression &pattern)
void | setRotationRoleReplace(const QString &replace)
void | setScaleRole(const QString &role)
void | setScaleRolePattern(const QRegularExpression &pattern)
void | setScaleRoleReplace(const QString &replace)
void | setXPosRole(const QString &role)
void | setXPosRolePattern(const QRegularExpression &pattern)
void | setXPosRoleReplace(const QString &replace)
void | setYPosRole(const QString &role)
void | setYPosRolePattern(const QRegularExpression &pattern)
void | setYPosRoleReplace(const QString &replace)
void | setZPosRole(const QString &role)
void | setZPosRolePattern(const QRegularExpression &pattern)
void | setZPosRoleReplace(const QString &replace)
QString | xPosRole() const
QRegularExpression | xPosRolePattern() const
QString | xPosRoleReplace() const
QString | yPosRole() const
QRegularExpression | yPosRolePattern() const
QString | yPosRoleReplace() const
QString | zPosRole() const
QRegularExpression | zPosRolePattern() const
QString | zPosRoleReplace() const

## Signals

void | itemModelChanged(const QAbstractItemModel *itemModel)
void | rotationRoleChanged(const QString &role)
void | rotationRolePatternChanged(const QRegularExpression &pattern)
void | rotationRoleReplaceChanged(const QString &replace)
void | scaleRoleChanged(const QString &role)
void | scaleRolePatternChanged(const QRegularExpression &pattern)
void | scaleRoleReplaceChanged(const QString &replace)
void | xPosRoleChanged(const QString &role)
void | xPosRolePatternChanged(const QRegularExpression &pattern)
void | xPosRoleReplaceChanged(const QString &replace)
void | yPosRoleChanged(const QString &role)
void | yPosRolePatternChanged(const QRegularExpression &pattern)
void | yPosRoleReplaceChanged(const QString &replace)
void | zPosRoleChanged(const QString &role)
void | zPosRolePatternChanged(const QRegularExpression &pattern)
void | zPosRoleReplaceChanged(const QString &replace)

## Detailed Description

QItemModelScatterDataProxy allows you to use QAbstractItemModel derived models as a data source for Q3DScatterWidgetItem. It maps roles of QAbstractItemModel to the XYZ-values of Q3DScatterWidgetItem points.

The data is resolved asynchronously whenever the mapping or the model changes. QScatterDataProxy::arrayReset() is emitted when the data has been resolved. However, inserts, removes, and single data item changes after the model initialization are resolved synchronously, unless the same frame also contains a change that causes the whole model to be resolved.

Mapping ignores rows and columns of the QAbstractItemModel and treats all items equally. It requires the model to provide roles for the data items that can be mapped to X, Y, and Z-values for the scatter points.

For example, assume that you have a custom QAbstractItemModel for storing various measurements done on material samples, providing data for roles such as "density", "hardness", and "conductivity". You could visualize these properties on a scatter graph using this proxy:

     // Map "density" value to X-axis, "hardness" to Y-axis and "conductivity" to Z-axis.
     QItemModelScatterDataProxy *proxy = new QItemModelScatterDataProxy(customModel,
                                                                        QStringLiteral("density"),
                                                                        QStringLiteral("hardness"),
                                                                        QStringLiteral("conductivity"));

If the fields of the model do not contain the data in the exact format you need, you can specify a search pattern regular expression and a replace rule for each role to get the value in a format you need. For more information on how the replacement using regular expressions works, see the QString::replace(const QRegularExpression &rx, const QString &after) function documentation. Note that using regular expressions has an impact on performance, so it's more efficient to utilize item models where doing search and replace is not necessary to get the desired values.

For example about using the search patterns in conjunction with the roles, see ItemModelBarDataProxy usage in Simple Bar Graph.

See also Qt Graphs Data Handling with 3D.

## Property Documentation

### itemModel : QAbstractItemModel*

This property holds the item model to use as a data source for a 3D scatter series.

Access functions:

QAbstractItemModel * | itemModel() const
void | setItemModel(QAbstractItemModel *itemModel)

Notifier signal:

void | itemModelChanged(const QAbstractItemModel *itemModel)

### rotationRole : QString

This property holds the item model role to map into item rotation.

The model may supply the value for rotation as either a variant that is directly convertible to QQuaternion or as one of the string representations: `"scalar,x,y,z"` or `"@angle,x,y,z"`. The first will construct the quaternion directly with the given values, and the second one will construct the quaternion using the QQuaternion::fromAxisAndAngle() method.

Access functions:

QString | rotationRole() const
void | setRotationRole(const QString &role)

Notifier signal:

void | rotationRoleChanged(const QString &role)

### rotationRolePattern : QRegularExpression

This property holds whether a search and replace is done on the value mapped by the rotation role before it is used as item rotation.

This property specifies the regular expression to find the portion of the mapped value to replace and rotationRoleReplace property contains the replacement string.

Access functions:

QRegularExpression | rotationRolePattern() const
void | setRotationRolePattern(const QRegularExpression &pattern)

Notifier signal:

void | rotationRolePatternChanged(const QRegularExpression &pattern)

See also rotationRole and rotationRoleReplace.

### rotationRoleReplace : QString

This property holds the replace content to be used in conjunction with the rotation role pattern.

Defaults to an 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.

Access functions:

QString | rotationRoleReplace() const
void | setRotationRoleReplace(const QString &replace)

Notifier signal:

void | rotationRoleReplaceChanged(const QString &replace)

See also rotationRole and rotationRolePattern.

### scaleRole : QString

This property holds the item model role to map into item scale.

The model may supply the value for scale as either a variant that is `"x,y,z"`. The first will construct the vector3d directly with the given values.

Access functions:

QString | scaleRole() const
void | setScaleRole(const QString &role)

Notifier signal:

void | scaleRoleChanged(const QString &role)

### scaleRolePattern : QRegularExpression

This property holds whether a search and replace is done on the value mapped by the scale role before it is used as item scale.

This property specifies the regular expression to find the portion of the mapped value to replace and scaleRoleReplace property contains the replacement string.

Access functions:

QRegularExpression | scaleRolePattern() const
void | setScaleRolePattern(const QRegularExpression &pattern)

Notifier signal:

void | scaleRolePatternChanged(const QRegularExpression &pattern)

See also scaleRole and scaleRoleReplace.

### scaleRoleReplace : QString

This property holds the replace content to be used in conjunction with the scale role pattern.

Defaults to an 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.

Access functions:

QString | scaleRoleReplace() const
void | setScaleRoleReplace(const QString &replace)

Notifier signal:

void | scaleRoleReplaceChanged(const QString &replace)

See also scaleRole and scaleRolePattern.

### xPosRole : QString

This property holds the item model role to map into the X position.

Access functions:

QString | xPosRole() const
void | setXPosRole(const QString &role)

Notifier signal:

void | xPosRoleChanged(const QString &role)

### xPosRolePattern : QRegularExpression

This property holds whether search and replace is done on the value mapped by the x position role before it is used as an item position value.

This property specifies the regular expression to find the portion of the mapped value to replace and xPosRoleReplace property contains the replacement string.

Access functions:

QRegularExpression | xPosRolePattern() const
void | setXPosRolePattern(const QRegularExpression &pattern)

Notifier signal:

void | xPosRolePatternChanged(const QRegularExpression &pattern)

See also xPosRole and xPosRoleReplace.

### xPosRoleReplace : QString

This property holds the replace content to be used in conjunction with the x position role pattern.

Defaults to an 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.

Access functions:

QString | xPosRoleReplace() const
void | setXPosRoleReplace(const QString &replace)

Notifier signal:

void | xPosRoleReplaceChanged(const QString &replace)

See also xPosRole and xPosRolePattern.

### yPosRole : QString

This property holds the item model role to map into the Y position.

Access functions:

QString | yPosRole() const
void | setYPosRole(const QString &role)

Notifier signal:

void | yPosRoleChanged(const QString &role)

### yPosRolePattern : QRegularExpression

This property holds whether a search and replace is done on the value mapped by the y position role before it is used as an item position value.

This property specifies the regular expression to find the portion of the mapped value to replace and yPosRoleReplace property contains the replacement string.

Access functions:

QRegularExpression | yPosRolePattern() const
void | setYPosRolePattern(const QRegularExpression &pattern)

Notifier signal:

void | yPosRolePatternChanged(const QRegularExpression &pattern)

See also yPosRole and yPosRoleReplace.

### yPosRoleReplace : QString

This property holds the replace content to be used in conjunction with the y position role pattern.

Defaults to an 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.

Access functions:

QString | yPosRoleReplace() const
void | setYPosRoleReplace(const QString &replace)

Notifier signal:

void | yPosRoleReplaceChanged(const QString &replace)

See also yPosRole and yPosRolePattern.

### zPosRole : QString

This property holds the item model role to map into the Z position.

Access functions:

QString | zPosRole() const
void | setZPosRole(const QString &role)

Notifier signal:

void | zPosRoleChanged(const QString &role)

### zPosRolePattern : QRegularExpression

This property holds whether a search and replace is done on the value mapped by the z position role before it is used as an item position value.

This property specifies the regular expression to find the portion of the mapped value to replace and zPosRoleReplace property contains the replacement string.

Access functions:

QRegularExpression | zPosRolePattern() const
void | setZPosRolePattern(const QRegularExpression &pattern)

Notifier signal:

void | zPosRolePatternChanged(const QRegularExpression &pattern)

See also zPosRole and zPosRoleReplace.

### zPosRoleReplace : QString

This property holds the replace content to be used in conjunction with the z position role pattern.

Defaults to an 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.

Access functions:

QString | zPosRoleReplace() const
void | setZPosRoleReplace(const QString &replace)

Notifier signal:

void | zPosRoleReplaceChanged(const QString &replace)

See also zPosRole and zPosRolePattern.

## Member Function Documentation

### `[explicit]` QItemModelScatterDataProxy::QItemModelScatterDataProxy(QObject *parent = nullptr)

Constructs QItemModelScatterDataProxy with optional parent.

### `[explicit]` QItemModelScatterDataProxy::QItemModelScatterDataProxy(QAbstractItemModel *itemModel, QObject *parent = nullptr)

Constructs QItemModelScatterDataProxy with itemModel and an optional parent. Proxy doesn't take ownership of the itemModel, as typically item models are owned by other controls.

### `[explicit]` QItemModelScatterDataProxy::QItemModelScatterDataProxy(QAbstractItemModel *itemModel, const QString &xPosRole, const QString &yPosRole, const QString &zPosRole, QObject *parent = nullptr)

Constructs QItemModelScatterDataProxy with itemModel and an optional parent. The proxy doesn't take ownership of the itemModel, as item models are typically owned by other controls. The xPosRole property is set to xPosRole, the yPosRole property to yPosRole, and the zPosRole property to zPosRole.

### `[explicit]` QItemModelScatterDataProxy::QItemModelScatterDataProxy(QAbstractItemModel *itemModel, const QString &xPosRole, const QString &yPosRole, const QString &zPosRole, const QString &rotationRole, QObject *parent = nullptr)

Constructs QItemModelScatterDataProxy with itemModel and an optional parent. The proxy doesn't take ownership of the itemModel, as item models are typically owned by other controls. The xPosRole property is set to xPosRole, the yPosRole property to yPosRole, the zPosRole property to zPosRole, and the rotationRole property to rotationRole.

### `[override virtual noexcept]` QItemModelScatterDataProxy::~QItemModelScatterDataProxy()

Destroys QItemModelScatterDataProxy.

### void QItemModelScatterDataProxy::remap(const QString &xPosRole, const QString &yPosRole, const QString &zPosRole, const QString &rotationRole)

Changes xPosRole, yPosRole, zPosRole, and rotationRole mapping.

### void QItemModelScatterDataProxy::remap(const QString &xPosRole, const QString &yPosRole, const QString &zPosRole, const QString &rotationRole, const QString &scaleRole)

Changes xPosRole, yPosRole, zPosRole, rotationRole, and scaleRole mapping.

### void QItemModelScatterDataProxy::setItemModel(QAbstractItemModel *itemModel)

Sets itemModel as the item model for Q3DScatterWidgetItem. Does not take ownership of the model, but does connect to it to listen for changes.

Note: Setter function for property itemModel.

See also itemModel().