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

PyQt6.QtGraphs.QItemModelSurfaceDataProxy

Inherits from QSurfaceDataProxy.

Description

Proxy class for presenting data in item models with Q3DSurfaceWidgetItem.

QItemModelSurfaceDataProxy allows you to use QAbstractItemModel derived models as a data source for Q3DSurfaceWidgetItem. It uses the defined mappings to map data from the model to rows, columns, and surface points of Q3DSurfaceWidgetItem graph.

Data is resolved asynchronously whenever the mapping or the model changes. arrayReset is emitted when the data has been resolved. However, when useModelCategories() property is set to true, single item changes are resolved synchronously, unless the same frame also contains a change that causes the whole model to be resolved.

Mappings can be used in the following ways:

For example, assume that you have a custom QAbstractItemModel storing surface topography data. Each item in the model has the roles “longitude”, “latitude”, and “height”. The item model already contains the data properly sorted so that longitudes and latitudes are first encountered in correct order, which enables us to utilize the row and column category autogeneration. You could do the following to display the data in a surface graph:

QItemModelSurfaceDataProxy *proxy = new QItemModelSurfaceDataProxy(customModel,

QStringLiteral("longitude"), // Row role

QStringLiteral("latitude"), // Column role

QStringLiteral("height")); // Y-position role

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

Enums

MultiMatchBehavior

Behavior types for multiMatchBehavior() property.

Member Value Description
Average 2 The position values from all items matching each row/column combination are averaged together and the averages are used as the surface point position.
CumulativeY 3 For X and Z values this acts just like Average, but Y values are added together instead of averaged and the total is used as the surface point Y position.
First 0 The position values are taken from the first item in the item model that matches each row/column combination.
Last 1 The position values are taken from the last item in the item model that matches each row/column combination.

Methods

__init__(parent: QObject = None)

Constructs QItemModelSurfaceDataProxy with an optional parent.


__init__(QAbstractItemModel, parent: QObject = None)

Constructs QItemModelSurfaceDataProxy with itemModel and an optional parent. The proxy doesn’t take ownership of the itemModel, as typically item models are owned by other controls.


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

Constructs QItemModelSurfaceDataProxy with itemModel and an optional parent. The proxy doesn’t take ownership of the itemModel, as typically item models are owned by other controls. The yPosRole() role is set to yPosRole. This constructor is meant to be used with models that have data properly sorted in rows and columns already, so it also sets useModelCategories() property to true.


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

Constructs QItemModelSurfaceDataProxy with itemModel and an optional parent. The proxy doesn’t take ownership of the itemModel, as typically item models are owned by other controls. The role mappings are set with rowRole, columnRole, and yPosRole. The zPosRole() and the xPosRole() are set to rowRole and columnRole, respectively.


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

Constructs QItemModelSurfaceDataProxy with itemModel and an optional parent. The proxy doesn’t take ownership of the itemModel, as typically item models are owned by other controls. The role mappings are set with rowRole, columnRole, xPosRole, yPosRole, and zPosRole.


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

Constructs QItemModelSurfaceDataProxy with itemModel and an optional parent. The proxy doesn’t take ownership of the itemModel, as typically item models are owned by other controls. The role mappings are set with rowRole, columnRole, and yPosRole. The zPosRole() and the xPosRole() are set to rowRole and columnRole, respectively. Row and column categories are set with rowCategories and columnCategories. This constructor also sets autoRowCategories() and autoColumnCategories() to false.


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

Constructs QItemModelSurfaceDataProxy with itemModel and an optional parent. The proxy doesn’t take ownership of the itemModel, as typically item models are owned by other controls. The role mappings are set with rowRole, columnRole, xPosRole, yPosRole, and zPosRole. Row and column categories are set with rowCategories and columnCategories. This constructor also sets autoRowCategories() and autoColumnCategories() to false.


autoColumnCategories() → bool


autoRowCategories() → bool


columnCategories() → list[str]


columnCategoryIndex(Optional[str]) → int

Returns the index of the specified category in the column categories list. If the category is not found, -1 is returned.

Note: If the automatic column categories generation is in use, this method will not return a valid index before the data in the model is resolved for the first time.


columnRole() → str

See also

setColumnRole().


columnRolePattern() → QRegularExpression


columnRoleReplace() → str


itemModel() → QAbstractItemModel


multiMatchBehavior() → MultiMatchBehavior


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

Changes rowRole, columnRole, xPosRole, yPosRole, zPosRole, rowCategories and columnCategories to the mapping.


rowCategories() → list[str]

See also

setRowCategories().


rowCategoryIndex(Optional[str]) → int

Returns the index of the specified category in the row categories list. If the row categories list is empty, -1 is returned.

Note: If the automatic row categories generation is in use, this method will not return a valid index before the data in the model is resolved for the first time.


rowRole() → str


rowRolePattern() → QRegularExpression

See also

setRowRolePattern().


rowRoleReplace() → str

See also

setRowRoleReplace().


setAutoColumnCategories(bool)


setAutoRowCategories(bool)

See also

autoRowCategories().


setColumnCategories(Iterable[Optional[str]])

See also

columnCategories().


setColumnRole(Optional[str])


setColumnRolePattern(QRegularExpression)

See also

columnRolePattern().


setColumnRoleReplace(Optional[str])

See also

columnRoleReplace().


setItemModel(QAbstractItemModel)

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


setMultiMatchBehavior(MultiMatchBehavior)

See also

multiMatchBehavior().


setRowCategories(Iterable[Optional[str]])

See also

rowCategories().


setRowRole(Optional[str])


setRowRolePattern(QRegularExpression)

See also

rowRolePattern().


setRowRoleReplace(Optional[str])

See also

rowRoleReplace().


setUseModelCategories(bool)

See also

useModelCategories().


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


useModelCategories() → bool


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

autoColumnCategoriesChanged(bool)

TODO


autoRowCategoriesChanged(bool)

TODO


columnCategoriesChanged()

TODO


columnRoleChanged(Optional[str])

TODO


columnRolePatternChanged(QRegularExpression)

TODO


columnRoleReplaceChanged(Optional[str])

TODO


itemModelChanged(QAbstractItemModel)

TODO


multiMatchBehaviorChanged(MultiMatchBehavior)

TODO


rowCategoriesChanged()

TODO


rowRoleChanged(Optional[str])

TODO


rowRolePatternChanged(QRegularExpression)

TODO


rowRoleReplaceChanged(Optional[str])

TODO


useModelCategoriesChanged(bool)

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