QItemModelScatterDataProxy Class

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

Header: #include <QItemModelScatterDataProxy>
CMake: find_package(Qt6 REQUIRED COMPONENTS DataVisualization)
target_link_libraries(mytarget PRIVATE Qt6::DataVisualization)
qmake: QT += datavisualization
Since: QtDataVisualization 1.0
Instantiated By: ItemModelScatterDataProxy
Inherits: QScatterDataProxy

Properties

Public Functions

virtual ~QItemModelScatterDataProxy()
QAbstractItemModel *itemModel() const
QString rotationRole() const
QRegularExpression rotationRolePattern() const
QString rotationRoleReplace() const
void setItemModel()
void setRotationRole()
void setRotationRolePattern()
void setRotationRoleReplace()
void setXPosRole()
void setXPosRolePattern()
void setXPosRoleReplace()
void setYPosRole()
void setYPosRolePattern()
void setYPosRoleReplace()
void setZPosRole()
void setZPosRolePattern()
void setZPosRoleReplace()
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

Detailed Description

QItemModelScatterDataProxy allows you to use QAbstractItemModel derived models as a data source for Q3DScatter. It maps roles of QAbstractItemModel to the XYZ-values of Q3DScatter 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 how the replace using regular expressions works, see QString::replace(const QRegularExpression &rx, const QString &after) function documentation. Note that using regular expressions has an impact on the 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 example.

See also Qt Data Visualization Data Handling.

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()

Notifier signal:

void itemModelChanged()

rotationRole : QString

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

The model may supply the value for rotation as either 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 given values, and the second one will construct the quaternion using QQuaternion::fromAxisAndAngle() method.

Access functions:

QString rotationRole() const
void setRotationRole()

Notifier signal:

void rotationRoleChanged()

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()

Notifier signal:

void rotationRolePatternChanged()

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()

Notifier signal:

void rotationRoleReplaceChanged()

See also rotationRole and rotationRolePattern.

xPosRole : QString

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

Access functions:

QString xPosRole() const
void setXPosRole()

Notifier signal:

void xPosRoleChanged()

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()

Notifier signal:

void xPosRolePatternChanged()

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()

Notifier signal:

void xPosRoleReplaceChanged()

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()

Notifier signal:

void yPosRoleChanged()

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()

Notifier signal:

void yPosRolePatternChanged()

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()

Notifier signal:

void yPosRoleReplaceChanged()

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()

Notifier signal:

void zPosRoleChanged()

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()

Notifier signal:

void zPosRolePatternChanged()

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()

Notifier signal:

void zPosRoleReplaceChanged()

See also zPosRole and zPosRolePattern.

Member Function Documentation

[virtual] QItemModelScatterDataProxy::~QItemModelScatterDataProxy()

Destroys QItemModelScatterDataProxy.