QItemModelSurfaceDataProxy

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

Inheritance diagram of PySide6.QtDataVisualization.QItemModelSurfaceDataProxy

Synopsis

Functions

Detailed Description

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

Data is resolved asynchronously whenever the mapping or the model changes. 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:

  • If useModelCategories property is set to true, this proxy will map rows and columns of QAbstractItemModel to rows and columns of Q3DSurface , and uses the value returned for DisplayRole as Y-position by default. Row and column headers are used for Z-position and X-position by default, if they can be converted to floats. Otherwise row and column indices are used. The Y-position role to be used can be redefined if DisplayRole is not suitable. The Z-position and X-position roles to be used can be redefined if the headers or indices are not suitable.

  • For models that do not have data already neatly sorted into rows and columns, such as QAbstractListModel based models, you can define a role from the model to map for each of row, column and Y-position.

  • If you do not want to include all data contained in the model, or the autogenerated rows and columns are not ordered as you wish, you can specify which rows and columns should be included and in which order by defining an explicit list of categories for either or both of rows and columns.

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 how the replace using regular expressions works, see 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 Qt Quick 2 Bars Example .

class PySide6.QtDataVisualization.QItemModelSurfaceDataProxy(itemModel[, parent=None])

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy(itemModel, rowRole, columnRole, xPosRole, yPosRole, zPosRole[, parent=None])

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy(itemModel, rowRole, columnRole, xPosRole, yPosRole, zPosRole, rowCategories, columnCategories[, parent=None])

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy(itemModel, rowRole, columnRole, yPosRole[, parent=None])

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy(itemModel, rowRole, columnRole, yPosRole, rowCategories, columnCategories[, parent=None])

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy(itemModel, yPosRole[, parent=None])

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy([parent=None])

Parameters

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

Constructs QItemModelSurfaceDataProxy with itemModel and optional parent. 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.

Constructs QItemModelSurfaceDataProxy with itemModel and optional parent. 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.

Constructs QItemModelSurfaceDataProxy with itemModel and optional parent. 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.

Constructs QItemModelSurfaceDataProxy with optional parent.

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.MultiMatchBehavior

Behavior types for multiMatchBehavior property.

Constant

Description

QItemModelSurfaceDataProxy.MMBFirst

The position values are taken from the first item in the item model that matches each row/column combination.

QItemModelSurfaceDataProxy.MMBLast

The position values are taken from the last item in the item model that matches each row/column combination.

QItemModelSurfaceDataProxy.MMBAverage

The position values from all items matching each row/column combination are averaged together and the averages are used as the surface point position.

QItemModelSurfaceDataProxy.MMBCumulativeY

For X and Z values this acts just like MMBAverage, but Y values are added together instead of averaged and the total is used as the surface point Y position.

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.autoColumnCategories()
Return type

bool

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.autoColumnCategoriesChanged(enable)
Parameters

enable – bool

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.autoRowCategories()
Return type

bool

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.autoRowCategoriesChanged(enable)
Parameters

enable – bool

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.columnCategories()
Return type

list of strings

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.columnCategoriesChanged()
PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.columnCategoryIndex(category)
Parameters

category – str

Return type

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.

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.columnRole()
Return type

str

See also

setColumnRole()

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.columnRoleChanged(role)
Parameters

role – str

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.columnRolePattern()
Return type

PySide6.QtCore.QRegularExpression

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.columnRolePatternChanged(pattern)
Parameters

patternPySide6.QtCore.QRegularExpression

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.columnRoleReplace()
Return type

str

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.columnRoleReplaceChanged(replace)
Parameters

replace – str

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.itemModel()
Return type

PySide6.QtCore.QAbstractItemModel

See also

setItemModel()

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.itemModelChanged(itemModel)
Parameters

itemModelPySide6.QtCore.QAbstractItemModel

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.multiMatchBehavior()
Return type

MultiMatchBehavior

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.multiMatchBehaviorChanged(behavior)
Parameters

behaviorMultiMatchBehavior

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.remap(rowRole, columnRole, xPosRole, yPosRole, zPosRole, rowCategories, columnCategories)
Parameters
  • rowRole – str

  • columnRole – str

  • xPosRole – str

  • yPosRole – str

  • zPosRole – str

  • rowCategories – list of strings

  • columnCategories – list of strings

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

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.rowCategories()
Return type

list of strings

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.rowCategoriesChanged()
PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.rowCategoryIndex(category)
Parameters

category – str

Return type

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.

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.rowRole()
Return type

str

See also

setRowRole()

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.rowRoleChanged(role)
Parameters

role – str

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.rowRolePattern()
Return type

PySide6.QtCore.QRegularExpression

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.rowRolePatternChanged(pattern)
Parameters

patternPySide6.QtCore.QRegularExpression

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.rowRoleReplace()
Return type

str

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.rowRoleReplaceChanged(replace)
Parameters

replace – str

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setAutoColumnCategories(enable)
Parameters

enable – bool

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setAutoRowCategories(enable)
Parameters

enable – bool

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setColumnCategories(categories)
Parameters

categories – list of strings

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setColumnRole(role)
Parameters

role – str

See also

columnRole()

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setColumnRolePattern(pattern)
Parameters

patternPySide6.QtCore.QRegularExpression

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setColumnRoleReplace(replace)
Parameters

replace – str

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setItemModel(itemModel)
Parameters

itemModelPySide6.QtCore.QAbstractItemModel

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

See also

itemModel()

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setMultiMatchBehavior(behavior)
Parameters

behaviorMultiMatchBehavior

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setRowCategories(categories)
Parameters

categories – list of strings

See also

rowCategories()

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setRowRole(role)
Parameters

role – str

See also

rowRole()

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setRowRolePattern(pattern)
Parameters

patternPySide6.QtCore.QRegularExpression

See also

rowRolePattern()

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setRowRoleReplace(replace)
Parameters

replace – str

See also

rowRoleReplace()

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setUseModelCategories(enable)
Parameters

enable – bool

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setXPosRole(role)
Parameters

role – str

See also

xPosRole()

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setXPosRolePattern(pattern)
Parameters

patternPySide6.QtCore.QRegularExpression

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setXPosRoleReplace(replace)
Parameters

replace – str

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setYPosRole(role)
Parameters

role – str

See also

yPosRole()

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setYPosRolePattern(pattern)
Parameters

patternPySide6.QtCore.QRegularExpression

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setYPosRoleReplace(replace)
Parameters

replace – str

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setZPosRole(role)
Parameters

role – str

See also

zPosRole()

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setZPosRolePattern(pattern)
Parameters

patternPySide6.QtCore.QRegularExpression

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.setZPosRoleReplace(replace)
Parameters

replace – str

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.useModelCategories()
Return type

bool

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.useModelCategoriesChanged(enable)
Parameters

enable – bool

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.xPosRole()
Return type

str

See also

setXPosRole()

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.xPosRoleChanged(role)
Parameters

role – str

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.xPosRolePattern()
Return type

PySide6.QtCore.QRegularExpression

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.xPosRolePatternChanged(pattern)
Parameters

patternPySide6.QtCore.QRegularExpression

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.xPosRoleReplace()
Return type

str

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.xPosRoleReplaceChanged(replace)
Parameters

replace – str

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.yPosRole()
Return type

str

See also

setYPosRole()

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.yPosRoleChanged(role)
Parameters

role – str

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.yPosRolePattern()
Return type

PySide6.QtCore.QRegularExpression

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.yPosRolePatternChanged(pattern)
Parameters

patternPySide6.QtCore.QRegularExpression

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.yPosRoleReplace()
Return type

str

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.yPosRoleReplaceChanged(replace)
Parameters

replace – str

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.zPosRole()
Return type

str

See also

setZPosRole()

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.zPosRoleChanged(role)
Parameters

role – str

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.zPosRolePattern()
Return type

PySide6.QtCore.QRegularExpression

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.zPosRolePatternChanged(pattern)
Parameters

patternPySide6.QtCore.QRegularExpression

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.zPosRoleReplace()
Return type

str

PySide6.QtDataVisualization.QItemModelSurfaceDataProxy.zPosRoleReplaceChanged(replace)
Parameters

replace – str