QItemModelScatterDataProxy Class

代理类,用于在Q3DScatterWidgetItem 项目模型中显示数据。更多

头文件: #include <QItemModelScatterDataProxy>
CMake: find_package(Qt6 REQUIRED COMPONENTS Graphs)
target_link_libraries(mytarget PRIVATE Qt6::Graphs)
qmake: QT += graphs
在 QML 中: ItemModelScatterDataProxy
继承: QScatterDataProxy

属性

公共功能

QItemModelScatterDataProxy(QObject *parent = nullptr)
QItemModelScatterDataProxy(QAbstractItemModel *itemModel, QObject *parent = nullptr)
QItemModelScatterDataProxy(QAbstractItemModel *itemModel, const QString &xPosRole, const QString &yPosRole, const QString &zPosRole, QObject *parent = nullptr)
QItemModelScatterDataProxy(QAbstractItemModel *itemModel, const QString &xPosRole, const QString &yPosRole, const QString &zPosRole, const QString &rotationRole, QObject *parent = nullptr)
virtual ~QItemModelScatterDataProxy() override
QAbstractItemModel *itemModel() const
void remap(const QString &xPosRole, const QString &yPosRole, const QString &zPosRole, const QString &rotationRole)
QString rotationRole() const
QRegularExpression rotationRolePattern() const
QString rotationRoleReplace() const
void setItemModel(QAbstractItemModel *itemModel)
void setRotationRole(const QString &role)
void setRotationRolePattern(const QRegularExpression &pattern)
void setRotationRoleReplace(const QString &replace)
void setXPosRole(const QString &role)
void setXPosRolePattern(const QRegularExpression &pattern)
void setXPosRoleReplace(const QString &replace)
void setYPosRole(const QString &role)
void setYPosRolePattern(const QRegularExpression &pattern)
void setYPosRoleReplace(const QString &replace)
void setZPosRole(const QString &role)
void setZPosRolePattern(const QRegularExpression &pattern)
void setZPosRoleReplace(const QString &replace)
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

信号

void itemModelChanged(const QAbstractItemModel *itemModel)
void rotationRoleChanged(const QString &role)
void rotationRolePatternChanged(const QRegularExpression &pattern)
void rotationRoleReplaceChanged(const QString &replace)
void xPosRoleChanged(const QString &role)
void xPosRolePatternChanged(const QRegularExpression &pattern)
void xPosRoleReplaceChanged(const QString &replace)
void yPosRoleChanged(const QString &role)
void yPosRolePatternChanged(const QRegularExpression &pattern)
void yPosRoleReplaceChanged(const QString &replace)
void zPosRoleChanged(const QString &role)
void zPosRolePatternChanged(const QRegularExpression &pattern)
void zPosRoleReplaceChanged(const QString &replace)

详细说明

QItemModelScatterDataProxy 允许您使用QAbstractItemModel 派生模型作为Q3DScatterWidgetItem 的数据源。它将QAbstractItemModel 的角色映射到Q3DScatterWidgetItem 点的 XYZ 值。

每当映射或模型发生变化时,数据都会被异步解析。QScatterDataProxy::arrayReset(数据解析完成后,会发出()。但是,模型初始化后的插入、移除和单个数据项的更改是同步解析的,除非同一帧也包含导致整个模型解析的更改。

映射会忽略QAbstractItemModel 的行和列,并对所有项目一视同仁。它要求模型为数据项提供可映射到散点的 X、Y 和 Z 值的角色。

例如,假设您有一个自定义的QAbstractItemModel ,用于存储对材料样本进行的各种测量,并为 "密度"、"硬度 "和 "导电性 "等角色提供数据。您可以使用该代理在散点图上可视化这些属性:

// 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"));

如果模型的字段不包含您所需格式的数据,您可以为每个角色指定一个搜索模式正则表达式和一个替换规则,以获得您所需格式的值。有关如何使用正则表达式进行替换的详细信息,请参阅QString::replace(constQRegularExpression &rx, constQString &after)函数文档。请注意,使用正则表达式会影响性能,因此在不需要使用搜索和替换来获取所需数值的情况下,使用项目模型会更有效。

有关结合角色使用搜索模式的示例,请参阅ItemModelBarDataProxy简单条形图中的用法。

另请参阅 Qt Graphs 3D 数据处理

属性文档

itemModel : QAbstractItemModel*

此属性包含用作 3D 散点序列数据源的项目模型。

访问功能:

QAbstractItemModel *itemModel() const
void setItemModel(QAbstractItemModel *itemModel)

通知信号:

void itemModelChanged(const QAbstractItemModel *itemModel)

rotationRole : QString

此属性包含映射到项目旋转的项目模型角色。

模型可以提供可直接转换为QQuaternion 的旋转值,也可以提供字符串表示:"scalar,x,y,z""@angle,x,y,z" 。前者将直接用给定值构建四元数,后者将使用QQuaternion::fromAxisAndAngle() 方法构建四元数。

访问函数:

QString rotationRole() const
void setRotationRole(const QString &role)

Notifier 信号:

void rotationRoleChanged(const QString &role)

rotationRolePattern : QRegularExpression

该属性表示是否在旋转角色映射的值用作项目旋转之前对其进行搜索和替换。

该属性指定正则表达式以查找要替换的映射值部分,rotationRoleReplace 属性包含替换字符串。

访问功能:

QRegularExpression rotationRolePattern() const
void setRotationRolePattern(const QRegularExpression &pattern)

Notifier 信号:

void rotationRolePatternChanged(const QRegularExpression &pattern)

另请参阅 rotationRolerotationRoleReplace

rotationRoleReplace : QString

该属性包含与旋转角色模式一起使用的替换内容。

默认为空字符串。有关如何使用正则表达式进行搜索和替换的更多信息,请参阅QString::replace(constQRegularExpression &rx, constQString &after)函数文档。

访问函数:

QString rotationRoleReplace() const
void setRotationRoleReplace(const QString &replace)

Notifier 信号:

void rotationRoleReplaceChanged(const QString &replace)

另请参见 rotationRolerotationRolePattern

xPosRole : QString

此属性包含映射到 X 位置的项目模型角色。

访问功能:

QString xPosRole() const
void setXPosRole(const QString &role)

通知信号:

void xPosRoleChanged(const QString &role)

xPosRolePattern : QRegularExpression

该属性表示是否在 x 位置角色映射的值用作项目位置值之前对其进行搜索和替换。

该属性指定正则表达式,用于查找要替换的映射值部分,xPosRoleReplace 属性包含替换字符串。

访问功能:

QRegularExpression xPosRolePattern() const
void setXPosRolePattern(const QRegularExpression &pattern)

Notifier 信号:

void xPosRolePatternChanged(const QRegularExpression &pattern)

另请参阅 xPosRolexPosRoleReplace

xPosRoleReplace : QString

该属性包含与 x 位置角色模式结合使用的替换内容。

默认为空字符串。有关使用正则表达式进行搜索和替换的工作原理,请参阅QString::replace(constQRegularExpression &rx, constQString &after) 函数文档。

访问函数:

QString xPosRoleReplace() const
void setXPosRoleReplace(const QString &replace)

Notifier 信号:

void xPosRoleReplaceChanged(const QString &replace)

另请参见 xPosRolexPosRolePattern

yPosRole : QString

此属性包含映射到 Y 位置的项目模型角色。

访问功能:

QString yPosRole() const
void setYPosRole(const QString &role)

通知信号:

void yPosRoleChanged(const QString &role)

yPosRolePattern : QRegularExpression

该属性用于确定是否在 y 位置角色映射的值用作项目位置值之前对其进行搜索和替换。

该属性指定正则表达式,用于查找要替换的映射值部分,yPosRoleReplace 属性包含替换字符串。

访问功能:

QRegularExpression yPosRolePattern() const
void setYPosRolePattern(const QRegularExpression &pattern)

Notifier 信号:

void yPosRolePatternChanged(const QRegularExpression &pattern)

另请参阅 yPosRoleyPosRoleReplace

yPosRoleReplace : QString

该属性包含与 y 位置角色模式结合使用的替换内容。

默认为空字符串。有关使用正则表达式进行搜索和替换的工作原理,请参阅QString::replace(constQRegularExpression &rx, constQString &after) 函数文档。

访问函数:

QString yPosRoleReplace() const
void setYPosRoleReplace(const QString &replace)

Notifier 信号:

void yPosRoleReplaceChanged(const QString &replace)

另请参见 yPosRoleyPosRolePattern

zPosRole : QString

该属性包含映射到 Z 位置的项目模型角色。

访问功能:

QString zPosRole() const
void setZPosRole(const QString &role)

通知信号:

void zPosRoleChanged(const QString &role)

zPosRolePattern : QRegularExpression

该属性表示是否在将 z 位置角色映射的值用作项目位置值之前对其进行搜索和替换。

该属性指定正则表达式,用于查找要替换的映射值部分,zPosRoleReplace 属性包含替换字符串。

访问功能:

QRegularExpression zPosRolePattern() const
void setZPosRolePattern(const QRegularExpression &pattern)

Notifier 信号:

void zPosRolePatternChanged(const QRegularExpression &pattern)

另请参见 zPosRolezPosRoleReplace

zPosRoleReplace : QString

该属性包含与 z 位置角色模式一起使用的替换内容。

默认为空字符串。有关如何使用正则表达式进行搜索和替换的更多信息,请参阅QString::replace(constQRegularExpression &rx, constQString &after)函数文档。

访问函数:

QString zPosRoleReplace() const
void setZPosRoleReplace(const QString &replace)

Notifier 信号:

void zPosRoleReplaceChanged(const QString &replace)

另请参见 zPosRolezPosRolePattern

成员函数文档

[explicit] QItemModelScatterDataProxy::QItemModelScatterDataProxy(QObject *parent = nullptr)

构造带有可选parent 的 QItemModelScatterDataProxy。

[explicit] QItemModelScatterDataProxy::QItemModelScatterDataProxy(QAbstractItemModel *itemModel, QObject *parent = nullptr)

itemModel 和一个可选的parent 构造 QItemModelScatterDataProxy。代理不拥有itemModel 的所有权,因为项目模型通常由其他控件拥有。

[explicit] QItemModelScatterDataProxy::QItemModelScatterDataProxy(QAbstractItemModel *itemModel, const QString &xPosRole, const QString &yPosRole, const QString &zPosRole, QObject *parent = nullptr)

itemModel 和一个可选的parent 构造 QItemModelScatterDataProxy。该代理不拥有itemModel 的所有权,因为项目模型通常由其他控件拥有。xPosRole 属性设置为xPosRoleyPosRole 属性设置为yPosRolezPosRole 属性设置为zPosRole

[explicit] QItemModelScatterDataProxy::QItemModelScatterDataProxy(QAbstractItemModel *itemModel, const QString &xPosRole, const QString &yPosRole, const QString &zPosRole, const QString &rotationRole, QObject *parent = nullptr)

itemModel 和一个可选的parent 构造 QItemModelScatterDataProxy。该代理不拥有itemModel 的所有权,因为项目模型通常由其他控件拥有。xPosRole 属性设置为xPosRoleyPosRole 属性设置为yPosRolezPosRole 属性设置为zPosRolerotationRole 属性设置为rotationRole

[override virtual noexcept] QItemModelScatterDataProxy::~QItemModelScatterDataProxy()

销毁QItemModelScatterDataProxy

void QItemModelScatterDataProxy::remap(const QString &xPosRole, const QString &yPosRole, const QString &zPosRole, const QString &rotationRole)

更改xPosRole,yPosRole,zPosRolerotationRole 映射。

void QItemModelScatterDataProxy::setItemModel(QAbstractItemModel *itemModel)

itemModel 设置为Q3DScatterWidgetItem 的项目模型。不拥有模型的所有权,但会连接到模型以监听更改。

注: 属性itemModel 的设置函数。

另请参阅 itemModel().

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.