QItemModelScatterDataProxy — PyQt Documentation v6.9.0 (original) (raw)

PyQt6.QtGraphs.QItemModelScatterDataProxy

Inherits from QScatterDataProxy.

Description

Proxy class for presenting data in item models with Q3DScatterWidgetItem.

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

Methods

__init__(parent: QObject = None)

Constructs QItemModelScatterDataProxy with optional parent.


__init__(QAbstractItemModel, parent: QObject = None)

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.


__init__(QAbstractItemModel, Optional[str], Optional[str], Optional[str], parent: QObject = None)

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.


__init__(QAbstractItemModel, Optional[str], Optional[str], Optional[str], Optional[str], parent: QObject = None)

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.


itemModel() → QAbstractItemModel


remap(Optional[str], Optional[str], Optional[str], Optional[str])

Changes xPosRole, yPosRole, zPosRole, and rotationRole mapping.


rotationRole() → str

See also

setRotationRole().


rotationRolePattern() → QRegularExpression


rotationRoleReplace() → str


setItemModel(QAbstractItemModel)

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


setRotationRole(Optional[str])


setRotationRolePattern(QRegularExpression)


setRotationRoleReplace(Optional[str])


setXPosRole(Optional[str])


setXPosRolePattern(QRegularExpression)

See also

xPosRolePattern().


setXPosRoleReplace(Optional[str])

See also

xPosRoleReplace().


setYPosRole(Optional[str])


setYPosRolePattern(QRegularExpression)

See also

yPosRolePattern().


setYPosRoleReplace(Optional[str])

See also

yPosRoleReplace().


setZPosRole(Optional[str])


setZPosRolePattern(QRegularExpression)

See also

zPosRolePattern().


setZPosRoleReplace(Optional[str])

See also

zPosRoleReplace().


xPosRole() → str


xPosRolePattern() → QRegularExpression

See also

setXPosRolePattern().


xPosRoleReplace() → str

See also

setXPosRoleReplace().


yPosRole() → str


yPosRolePattern() → QRegularExpression

See also

setYPosRolePattern().


yPosRoleReplace() → str

See also

setYPosRoleReplace().


zPosRole() → str


zPosRolePattern() → QRegularExpression

See also

setZPosRolePattern().


zPosRoleReplace() → str

See also

setZPosRoleReplace().

Signals

itemModelChanged(QAbstractItemModel)

TODO


rotationRoleChanged(Optional[str])

TODO


rotationRolePatternChanged(QRegularExpression)

TODO


rotationRoleReplaceChanged(Optional[str])

TODO


xPosRoleChanged(Optional[str])

TODO


xPosRolePatternChanged(QRegularExpression)

TODO


xPosRoleReplaceChanged(Optional[str])

TODO


yPosRoleChanged(Optional[str])

TODO


yPosRolePatternChanged(QRegularExpression)

TODO


yPosRoleReplaceChanged(Optional[str])

TODO


zPosRoleChanged(Optional[str])

TODO


zPosRolePatternChanged(QRegularExpression)

TODO


zPosRoleReplaceChanged(Optional[str])

TODO