- class QItemModelSurfaceDataProxy¶
Proxy class for presenting data in item models with
Q3DSurfaceWidgetItem
. More…Synopsis¶
Properties¶
autoColumnCategoriesᅟ
- Whether column categories are generated automaticallyautoRowCategoriesᅟ
- Whether row categories are generated automaticallycolumnCategoriesᅟ
- Column categories for the mappingcolumnRoleᅟ
- Item model role to map to the column categorycolumnRolePatternᅟ
- Whether a search and replace is done on the value mapped by the column role before it is used as a column categorycolumnRoleReplaceᅟ
- Replacement content to be used in conjunction with a column role patternitemModelᅟ
- Item model used as a data source for the 3D surfacemultiMatchBehaviorᅟ
- How multiple matches for each row/column combination are handledrowCategoriesᅟ
- Row categories for the mappingrowRoleᅟ
- Item model role to map to the row categoryrowRolePatternᅟ
- Whether a search and replace is performed on the value mapped by the row role before it is used as a row categoryrowRoleReplaceᅟ
- Replacement content to be used in conjunction with the row role patternuseModelCategoriesᅟ
- Whether row and column roles and categories are used for mappingxPosRoleᅟ
- Item model role to map to the X positionxPosRolePatternᅟ
- Whether a search and replace is done on the value mapped by the x position role before it is used as an item position valuexPosRoleReplaceᅟ
- Replacement content to be used in conjunction with an x position role patternyPosRoleᅟ
- Item model role to map to the Y positionyPosRolePatternᅟ
- Whether a search and replace is done on the value mapped by the y position role before it is used as an item position valueyPosRoleReplaceᅟ
- Replacement content to be used in conjunction with an y position role patternzPosRoleᅟ
- Item model role to map to the Z positionzPosRolePatternᅟ
- Whether a search and replace is done on the value mapped by the z position role before it is used as an item position valuezPosRoleReplaceᅟ
- Replacement content to be used in conjunction with a z position role pattern
Methods¶
def
__init__()
def
columnRole()
def
itemModel()
def
remap()
def
rowCategories()
def
rowRole()
def
rowRolePattern()
def
rowRoleReplace()
def
setColumnRole()
def
setItemModel()
def
setRowRole()
def
setXPosRole()
def
setYPosRole()
def
setZPosRole()
def
xPosRole()
def
yPosRole()
def
zPosRole()
Signals¶
def
rowRoleChanged()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
QItemModelSurfaceDataProxy
allows you to use QAbstractItemModel derived models as a data source forQ3DSurfaceWidgetItem
. It uses the defined mappings to map data from the model to rows, columns, and surface points ofQ3DSurfaceWidgetItem
graph.Data is resolved asynchronously whenever the mapping or the model changes.
arrayReset()
is emitted when the data has been resolved. However, whenuseModelCategories
property is set totrue
, 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 totrue
, this proxy will map rows and columns of QAbstractItemModel to rows and columns ofQ3DSurfaceWidgetItem
, and uses the value returned for Qt::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 Qt::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 the 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:
proxy = QItemModelSurfaceDataProxy(customModel,() "longitude", // Row role "latitude", // Column role "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 .
See also
Qt Graphs Data Handling with 3D
- class MultiMatchBehavior¶
Behavior types for
multiMatchBehavior
property.Constant
Description
QItemModelSurfaceDataProxy.MultiMatchBehavior.First
The position values are taken from the first item in the item model that matches each row/column combination.
QItemModelSurfaceDataProxy.MultiMatchBehavior.Last
The position values are taken from the last item in the item model that matches each row/column combination.
QItemModelSurfaceDataProxy.MultiMatchBehavior.Average
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.MultiMatchBehavior.CumulativeY
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.
Note
Properties can be used directly when
from __feature__ import true_property
is used or via accessor functions otherwise.- property autoColumnCategoriesᅟ: bool¶
This property holds Whether column categories are generated automatically..
When set to
true
, the mapping ignores any explicitly set column categories and overwrites them with automatically generated ones whenever the data from the model is resolved. Defaults totrue
.- Access functions:
- property autoRowCategoriesᅟ: bool¶
This property holds Whether row categories are generated automatically..
When set to
true
, the mapping ignores any explicitly set row categories and overwrites them with automatically generated ones whenever the data from the model is resolved. Defaults totrue
.- Access functions:
- property columnCategoriesᅟ: list of strings¶
This property holds The column categories for the mapping..
- Access functions:
- property columnRoleᅟ: str¶
This property holds The item model role to map to the column category..
In addition to defining which column the data belongs to, the value indicated by the column role is also set as the X-coordinate value of
QSurfaceDataItem
when model data is resolved, unless a separate x-position role is also defined.- Access functions:
- property columnRolePatternᅟ: QRegularExpression¶
This property holds Whether a search and replace is done on the value mapped by the column role before it is used as a column category..
This property specifies the regular expression to find the portion of the mapped value to replace and the
columnRoleReplace
property contains the replacement string.See also
- Access functions:
- property columnRoleReplaceᅟ: str¶
This property holds The replacement content to be used in conjunction with a column role pattern..
Defaults to an empty string. For more information on how the search and replace using regular expressions works, see the QString::replace(const QRegularExpression &rx, const QString &after) function documentation.
See also
- Access functions:
- property itemModelᅟ: QAbstractItemModel¶
This property holds The item model used as a data source for the 3D surface..
- Access functions:
- property multiMatchBehaviorᅟ: QItemModelSurfaceDataProxy.MultiMatchBehavior¶
This property holds How multiple matches for each row/column combination are handled..
Defaults to Last.
For example, you might have an item model with timestamped data taken at irregular intervals and you want to visualize an average position of data items on each hour with a surface graph. This can be done by specifying row and column categories so that each surface point represents an hour, and setting this property to Average.
- Access functions:
- property rowCategoriesᅟ: list of strings¶
This property holds The row categories for the mapping..
- Access functions:
- property rowRoleᅟ: str¶
This property holds The item model role to map to the row category..
In addition to defining which row the data belongs to, the value indicated by the row role is also set as the Z-coordinate value of
QSurfaceDataItem
when model data is resolved, unless a separate z-position role is also defined.- Access functions:
- property rowRolePatternᅟ: QRegularExpression¶
This property holds Whether a search and replace is performed on the value mapped by the row role before it is used as a row category..
This property specifies the regular expression to find the portion of the mapped value to replace and the
rowRoleReplace
property contains the replacement string.See also
- Access functions:
- property rowRoleReplaceᅟ: str¶
This property holds The replacement content to be used in conjunction with the row 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.
See also
- Access functions:
- property useModelCategoriesᅟ: bool¶
This property holds Whether row and column roles and categories are used for mapping..
When set to
true
, the mapping ignores row and column roles and categories, and uses the rows and columns from the model instead. Defaults tofalse
.- Access functions:
- property xPosRoleᅟ: str¶
This property holds The item model role to map to the X position..
If this role is not defined,
columnRole
is used to determine the X-coordinate value of the resolvedQSurfaceDataItem
objects.- Access functions:
- property xPosRolePatternᅟ: QRegularExpression¶
This property holds Whether a 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 the
xPosRoleReplace
property contains the replacement string.See also
- Access functions:
- property xPosRoleReplaceᅟ: str¶
This property holds The replacement content to be used in conjunction with an x position role pattern..
Defaults to an empty string. For more information on how the search and replace using regular expressions works, see the QString::replace(const QRegularExpression &rx, const QString &after) function documentation.
See also
- Access functions:
- property yPosRoleᅟ: str¶
This property holds The item model role to map to the Y position..
- Access functions:
- property 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 the
yPosRoleReplace
property contains the replacement string.See also
- Access functions:
- property yPosRoleReplaceᅟ: str¶
This property holds The replacement content to be used in conjunction with an y position role pattern..
Defaults to an empty string. For more information on how the search and replace using regular expressions works, see the QString::replace(const QRegularExpression &rx, const QString &after) function documentation.
See also
- Access functions:
- property zPosRoleᅟ: str¶
This property holds The item model role to map to the Z position..
If this role is not defined,
rowRole
is used to determine the Z-coordinate value of resolvedQSurfaceDataItem
objects.- Access functions:
- property 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 the
zPosRoleReplace
property contains the replacement string.See also
- Access functions:
- property zPosRoleReplaceᅟ: str¶
This property holds The replacement content to be used in conjunction with a z position role pattern..
Defaults to an empty string. For more information on how the search and replace using regular expressions works, see the QString::replace(const QRegularExpression &rx, const QString &after) function documentation.
See also
- Access functions:
Constructs
QItemModelSurfaceDataProxy
with an optionalparent
.- __init__(itemModel[, parent=None])
- Parameters:
itemModel –
QAbstractItemModel
parent –
QObject
Constructs
QItemModelSurfaceDataProxy
withitemModel
and an optionalparent
. The proxy doesn’t take ownership of theitemModel
, as typically item models are owned by other controls.- __init__(itemModel, yPosRole[, parent=None])
- Parameters:
itemModel –
QAbstractItemModel
yPosRole – str
parent –
QObject
Constructs
QItemModelSurfaceDataProxy
withitemModel
and an optionalparent
. The proxy doesn’t take ownership of theitemModel
, as typically item models are owned by other controls. TheyPosRole
role is set toyPosRole
. This constructor is meant to be used with models that have data properly sorted in rows and columns already, so it also setsuseModelCategories
property totrue
.- __init__(itemModel, rowRole, columnRole, yPosRole[, parent=None])
- Parameters:
itemModel –
QAbstractItemModel
rowRole – str
columnRole – str
yPosRole – str
parent –
QObject
Constructs
QItemModelSurfaceDataProxy
withitemModel
and an optionalparent
. The proxy doesn’t take ownership of theitemModel
, as typically item models are owned by other controls. The role mappings are set withrowRole
,columnRole
, andyPosRole
. ThezPosRole
and thexPosRole
are set torowRole
andcolumnRole
, respectively.- __init__(itemModel, rowRole, columnRole, xPosRole, yPosRole, zPosRole[, parent=None])
- Parameters:
itemModel –
QAbstractItemModel
rowRole – str
columnRole – str
xPosRole – str
yPosRole – str
zPosRole – str
parent –
QObject
Constructs
QItemModelSurfaceDataProxy
withitemModel
and an optionalparent
. The proxy doesn’t take ownership of theitemModel
, as typically item models are owned by other controls. The role mappings are set withrowRole
,columnRole
,xPosRole
,yPosRole
, andzPosRole
.- __init__(itemModel, rowRole, columnRole, yPosRole, rowCategories, columnCategories[, parent=None])
- Parameters:
itemModel –
QAbstractItemModel
rowRole – str
columnRole – str
yPosRole – str
rowCategories – list of strings
columnCategories – list of strings
parent –
QObject
Constructs
QItemModelSurfaceDataProxy
withitemModel
and an optionalparent
. The proxy doesn’t take ownership of theitemModel
, as typically item models are owned by other controls. The role mappings are set withrowRole
,columnRole
, andyPosRole
. ThezPosRole
and thexPosRole
are set torowRole
andcolumnRole
, respectively. Row and column categories are set withrowCategories
andcolumnCategories
. This constructor also setsautoRowCategories
andautoColumnCategories
to false.- __init__(itemModel, rowRole, columnRole, xPosRole, yPosRole, zPosRole, rowCategories, columnCategories[, parent=None])
- Parameters:
itemModel –
QAbstractItemModel
rowRole – str
columnRole – str
xPosRole – str
yPosRole – str
zPosRole – str
rowCategories – list of strings
columnCategories – list of strings
parent –
QObject
Constructs
QItemModelSurfaceDataProxy
withitemModel
and an optionalparent
. The proxy doesn’t take ownership of theitemModel
, as typically item models are owned by other controls. The role mappings are set withrowRole
,columnRole
,xPosRole
,yPosRole
, andzPosRole
. Row and column categories are set withrowCategories
andcolumnCategories
. This constructor also setsautoRowCategories
andautoColumnCategories
to false.- autoColumnCategories()¶
- Return type:
bool
See also
Getter of property
autoColumnCategoriesᅟ
.- autoColumnCategoriesChanged(enable)¶
- Parameters:
enable – bool
Notification signal of property
autoColumnCategoriesᅟ
.- autoRowCategories()¶
- Return type:
bool
See also
Getter of property
autoRowCategoriesᅟ
.- autoRowCategoriesChanged(enable)¶
- Parameters:
enable – bool
Notification signal of property
autoRowCategoriesᅟ
.- columnCategories()¶
- Return type:
list of strings
See also
Getter of property
columnCategoriesᅟ
.- columnCategoriesChanged()¶
Notification signal of property
columnCategoriesᅟ
.- 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.
- columnRole()¶
- Return type:
str
See also
Getter of property
columnRoleᅟ
.- columnRoleChanged(role)¶
- Parameters:
role – str
Notification signal of property
columnRoleᅟ
.- columnRolePattern()¶
- Return type:
See also
Getter of property
columnRolePatternᅟ
.- columnRolePatternChanged(pattern)¶
- Parameters:
pattern –
QRegularExpression
Notification signal of property
columnRolePatternᅟ
.- columnRoleReplace()¶
- Return type:
str
See also
Getter of property
columnRoleReplaceᅟ
.- columnRoleReplaceChanged(replace)¶
- Parameters:
replace – str
Notification signal of property
columnRoleReplaceᅟ
.- itemModel()¶
- Return type:
See also
Getter of property
itemModelᅟ
.- itemModelChanged(itemModel)¶
- Parameters:
itemModel –
QAbstractItemModel
Notification signal of property
itemModelᅟ
.- multiMatchBehavior()¶
- Return type:
See also
Getter of property
multiMatchBehaviorᅟ
.- multiMatchBehaviorChanged(behavior)¶
- Parameters:
behavior –
MultiMatchBehavior
Notification signal of property
multiMatchBehaviorᅟ
.- 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
andcolumnCategories
to the mapping.- rowCategories()¶
- Return type:
list of strings
See also
Getter of property
rowCategoriesᅟ
.- rowCategoriesChanged()¶
Notification signal of property
rowCategoriesᅟ
.- 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.
- rowRole()¶
- Return type:
str
See also
Getter of property
rowRoleᅟ
.- rowRoleChanged(role)¶
- Parameters:
role – str
Notification signal of property
rowRoleᅟ
.- rowRolePattern()¶
- Return type:
See also
Getter of property
rowRolePatternᅟ
.- rowRolePatternChanged(pattern)¶
- Parameters:
pattern –
QRegularExpression
Notification signal of property
rowRolePatternᅟ
.- rowRoleReplace()¶
- Return type:
str
See also
Getter of property
rowRoleReplaceᅟ
.- rowRoleReplaceChanged(replace)¶
- Parameters:
replace – str
Notification signal of property
rowRoleReplaceᅟ
.- setAutoColumnCategories(enable)¶
- Parameters:
enable – bool
See also
Setter of property
autoColumnCategoriesᅟ
.- setAutoRowCategories(enable)¶
- Parameters:
enable – bool
See also
Setter of property
autoRowCategoriesᅟ
.- setColumnCategories(categories)¶
- Parameters:
categories – list of strings
See also
Setter of property
columnCategoriesᅟ
.- setColumnRole(role)¶
- Parameters:
role – str
See also
Setter of property
columnRoleᅟ
.- setColumnRolePattern(pattern)¶
- Parameters:
pattern –
QRegularExpression
See also
Setter of property
columnRolePatternᅟ
.- setColumnRoleReplace(replace)¶
- Parameters:
replace – str
See also
Setter of property
columnRoleReplaceᅟ
.- setItemModel(itemModel)¶
- Parameters:
itemModel –
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
Setter of property
itemModelᅟ
.- setMultiMatchBehavior(behavior)¶
- Parameters:
behavior –
MultiMatchBehavior
See also
Setter of property
multiMatchBehaviorᅟ
.- setRowCategories(categories)¶
- Parameters:
categories – list of strings
See also
Setter of property
rowCategoriesᅟ
.Setter of property
rowRoleᅟ
.- setRowRolePattern(pattern)¶
- Parameters:
pattern –
QRegularExpression
See also
Setter of property
rowRolePatternᅟ
.- setRowRoleReplace(replace)¶
- Parameters:
replace – str
See also
Setter of property
rowRoleReplaceᅟ
.- setUseModelCategories(enable)¶
- Parameters:
enable – bool
See also
Setter of property
useModelCategoriesᅟ
.- setXPosRole(role)¶
- Parameters:
role – str
See also
Setter of property
xPosRoleᅟ
.- setXPosRolePattern(pattern)¶
- Parameters:
pattern –
QRegularExpression
See also
Setter of property
xPosRolePatternᅟ
.- setXPosRoleReplace(replace)¶
- Parameters:
replace – str
See also
Setter of property
xPosRoleReplaceᅟ
.- setYPosRole(role)¶
- Parameters:
role – str
See also
Setter of property
yPosRoleᅟ
.- setYPosRolePattern(pattern)¶
- Parameters:
pattern –
QRegularExpression
See also
Setter of property
yPosRolePatternᅟ
.- setYPosRoleReplace(replace)¶
- Parameters:
replace – str
See also
Setter of property
yPosRoleReplaceᅟ
.- setZPosRole(role)¶
- Parameters:
role – str
See also
Setter of property
zPosRoleᅟ
.- setZPosRolePattern(pattern)¶
- Parameters:
pattern –
QRegularExpression
See also
Setter of property
zPosRolePatternᅟ
.- setZPosRoleReplace(replace)¶
- Parameters:
replace – str
See also
Setter of property
zPosRoleReplaceᅟ
.- useModelCategories()¶
- Return type:
bool
See also
Getter of property
useModelCategoriesᅟ
.- useModelCategoriesChanged(enable)¶
- Parameters:
enable – bool
Notification signal of property
useModelCategoriesᅟ
.- xPosRole()¶
- Return type:
str
See also
Getter of property
xPosRoleᅟ
.- xPosRoleChanged(role)¶
- Parameters:
role – str
Notification signal of property
xPosRoleᅟ
.- xPosRolePattern()¶
- Return type:
See also
Getter of property
xPosRolePatternᅟ
.- xPosRolePatternChanged(pattern)¶
- Parameters:
pattern –
QRegularExpression
Notification signal of property
xPosRolePatternᅟ
.- xPosRoleReplace()¶
- Return type:
str
See also
Getter of property
xPosRoleReplaceᅟ
.- xPosRoleReplaceChanged(replace)¶
- Parameters:
replace – str
Notification signal of property
xPosRoleReplaceᅟ
.- yPosRole()¶
- Return type:
str
See also
Getter of property
yPosRoleᅟ
.- yPosRoleChanged(role)¶
- Parameters:
role – str
Notification signal of property
yPosRoleᅟ
.- yPosRolePattern()¶
- Return type:
See also
Getter of property
yPosRolePatternᅟ
.- yPosRolePatternChanged(pattern)¶
- Parameters:
pattern –
QRegularExpression
Notification signal of property
yPosRolePatternᅟ
.- yPosRoleReplace()¶
- Return type:
str
See also
Getter of property
yPosRoleReplaceᅟ
.- yPosRoleReplaceChanged(replace)¶
- Parameters:
replace – str
Notification signal of property
yPosRoleReplaceᅟ
.- zPosRole()¶
- Return type:
str
See also
Getter of property
zPosRoleᅟ
.- zPosRoleChanged(role)¶
- Parameters:
role – str
Notification signal of property
zPosRoleᅟ
.- zPosRolePattern()¶
- Return type:
See also
Getter of property
zPosRolePatternᅟ
.- zPosRolePatternChanged(pattern)¶
- Parameters:
pattern –
QRegularExpression
Notification signal of property
zPosRolePatternᅟ
.- zPosRoleReplace()¶
- Return type:
str
See also
Getter of property
zPosRoleReplaceᅟ
.- zPosRoleReplaceChanged(replace)¶
- Parameters:
replace – str
Notification signal of property
zPosRoleReplaceᅟ
.