Qt3DCore::QAttribute Class
class Qt3DCore::QAttribute定义了一个属性,以及如何从QBuffer 中读取数据。更多内容...
| 头文件: | #include <Qt3DCore/QAttribute> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS 3DCore) target_link_libraries(mytarget PRIVATE Qt6::3DCore) |
| qmake: | QT += 3dcore |
| 在 QML 中: | Attribute |
| 继承自: | Qt3DCore::QNode |
| 状态: | 已弃用 |
该类已弃用。我们强烈建议不要在新代码中使用它。
公共类型
| enum | AttributeType { VertexAttribute, IndexAttribute, DrawIndirectAttribute } |
| enum | VertexBaseType { Byte, UnsignedByte, Short, UnsignedShort, Int, …, Double } |
属性
|
|
公共函数
| QAttribute(Qt3DCore::QNode *parent = nullptr) | |
| QAttribute(Qt3DCore::QBuffer *buf, Qt3DCore::QAttribute::VertexBaseType type, uint dataSize, uint count, uint offset = 0, uint stride = 0, Qt3DCore::QNode *parent = nullptr) | |
| QAttribute(Qt3DCore::QBuffer *buf, const QString &name, Qt3DCore::QAttribute::VertexBaseType type, uint dataSize, uint count, uint offset = 0, uint stride = 0, Qt3DCore::QNode *parent = nullptr) | |
| Qt3DCore::QAttribute::AttributeType | attributeType() const |
| Qt3DCore::QBuffer * | buffer() const |
| uint | byteOffset() const |
| uint | byteStride() const |
| uint | count() const |
| uint | divisor() const |
| QString | name() const |
| Qt3DCore::QAttribute::VertexBaseType | vertexBaseType() const |
| uint | vertexSize() const |
公共槽位
| void | setAttributeType(Qt3DCore::QAttribute::AttributeType attributeType) |
| void | setBuffer(Qt3DCore::QBuffer *buffer) |
| void | setByteOffset(uint byteOffset) |
| void | setByteStride(uint byteStride) |
| void | setCount(uint count) |
| void | setDivisor(uint divisor) |
| void | setName(const QString &name) |
| void | setVertexBaseType(Qt3DCore::QAttribute::VertexBaseType type) |
| void | setVertexSize(uint size) |
信号
| void | attributeTypeChanged(Qt3DCore::QAttribute::AttributeType attributeType) |
| void | bufferChanged(Qt3DCore::QBuffer *buffer) |
| void | byteOffsetChanged(uint byteOffset) |
| void | byteStrideChanged(uint byteStride) |
| void | countChanged(uint count) |
| void | dataSizeChanged(uint vertexSize) |
| void | dataTypeChanged(Qt3DCore::QAttribute::VertexBaseType vertexBaseType) |
| void | divisorChanged(uint divisor) |
| void | nameChanged(const QString &name) |
| void | vertexBaseTypeChanged(Qt3DCore::QAttribute::VertexBaseType vertexBaseType) |
| void | vertexSizeChanged(uint vertexSize) |
静态公共成员
| QString | defaultColorAttributeName() |
| QString | defaultJointIndicesAttributeName() |
| QString | defaultJointWeightsAttributeName() |
| QString | defaultNormalAttributeName() |
| QString | defaultPositionAttributeName() |
| QString | defaultTangentAttributeName() |
| QString | defaultTextureCoordinate1AttributeName() |
| QString | defaultTextureCoordinate2AttributeName() |
| QString | defaultTextureCoordinateAttributeName() |
相关的非成员
详细说明
属性有 3 种类型。
- VertexAttribute:用于定义按顶点读取的数据
- IndexAttribute:用于在需要使用索引绘制调用时定义顶点索引
- DrawIndirectAttribute:用于指定在使用间接绘制调用时所用的 DrawIndirect 缓冲区
注意:当 属性类型为DrawIndirectAttribute时 ,仅 count、stride 和 offset 相关。
在提供自定义属性时,建议使用诸如 `QAttribute::defaultPositionAttributeName()` 等辅助函数来命名属性,这样可以确保您的几何体与 `Qt3DExtras ` 模块中提供的拾取功能和各种材质兼容。
另请参阅 QBuffer 。
成员类型文档
enum QAttribute::AttributeType
属性的类型。
| 常量 | 值 |
|---|---|
Qt3DCore::QAttribute::VertexAttribute | 0 |
Qt3DCore::QAttribute::IndexAttribute | 1 |
Qt3DCore::QAttribute::DrawIndirectAttribute | 2 |
enum QAttribute::VertexBaseType
数据的类型。
| 常量 | 值 |
|---|---|
Qt3DCore::QAttribute::Byte | 0 |
Qt3DCore::QAttribute::UnsignedByte | 1 |
Qt3DCore::QAttribute::Short | 2 |
Qt3DCore::QAttribute::UnsignedShort | 3 |
Qt3DCore::QAttribute::Int | 4 |
Qt3DCore::QAttribute::UnsignedInt | 5 |
Qt3DCore::QAttribute::HalfFloat | 6 |
Qt3DCore::QAttribute::Float | 7 |
Qt3DCore::QAttribute::Double | 8 |
属性文档
attributeType : AttributeType
存储属性类型。
访问函数:
| Qt3DCore::QAttribute::AttributeType | attributeType() const |
| void | setAttributeType(Qt3DCore::QAttribute::AttributeType attributeType) |
通知信号:
| void | attributeTypeChanged(Qt3DCore::QAttribute::AttributeType attributeType) |
buffer : Qt3DCore::QBuffer*
保存缓冲区。
访问函数:
| Qt3DCore::QBuffer * | buffer() const |
| void | setBuffer(Qt3DCore::QBuffer *buffer) |
通知信号:
| void | bufferChanged(Qt3DCore::QBuffer *buffer) |
byteOffset : uint
存储字节偏移量。
访问函数:
| uint | byteOffset() const |
| void | setByteOffset(uint byteOffset) |
通知器信号:
| void | byteOffsetChanged(uint byteOffset) |
byteStride : uint
存储字节步长。
访问函数:
| uint | byteStride() const |
| void | setByteStride(uint byteStride) |
通知器信号:
| void | byteStrideChanged(uint byteStride) |
count : uint
保存计数。
访问函数:
| uint | count() const |
| void | setCount(uint count) |
通知信号:
| void | countChanged(uint count) |
[read-only] defaultColorAttributeName : const QString
该属性存储默认颜色属性的名称。
返回默认颜色属性的名称:“vertexColor”。
访问函数:
| QString | defaultColorAttributeName() | [see note below] |
注意:此 函数可通过元对象系统以及从 QML 中调用。参见Q_INVOKABLE 。
[read-only] defaultJointIndicesAttributeName : const QString
该属性存储默认关节索引属性的名称。
返回默认关节索引属性的名称:“vertexJointIndices”。
访问函数:
| QString | defaultJointIndicesAttributeName() |
[read-only] defaultJointWeightsAttributeName : const QString
该属性存储默认关节权重属性的名称。
返回默认关节权重属性的名称:“vertexJointWeights”。
访问函数:
| QString | defaultJointWeightsAttributeName() |
[read-only] defaultNormalAttributeName : const QString
该属性存储默认法线属性的名称。
返回默认法线属性的名称:“vertexNormal”。
访问函数:
| QString | defaultNormalAttributeName() | [see note below] |
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[read-only] defaultPositionAttributeName : const QString
该属性存储默认位置属性的名称。
返回默认位置属性的名称:“vertexPosition”。
访问函数:
| QString | defaultPositionAttributeName() | [see note below] |
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[read-only] defaultTangentAttributeName : const QString
该属性存储默认切线属性的名称。
返回默认切线属性的名称:“vertexTangent”。
访问函数:
| QString | defaultTangentAttributeName() | [see note below] |
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[read-only] defaultTextureCoordinate1AttributeName : const QString
该属性存储了纹理坐标第二层的默认属性名称。
返回纹理坐标第二层的默认属性名称:“vertexTexCoord1”。
访问函数:
| QString | defaultTextureCoordinate1AttributeName() |
[read-only] defaultTextureCoordinate2AttributeName : const QString
该属性存储纹理坐标第三层的默认属性名称。
返回纹理坐标第三层的默认属性名称:“vertexTexCoord2”。
访问函数:
| QString | defaultTextureCoordinate2AttributeName() |
[read-only] defaultTextureCoordinateAttributeName : const QString
该属性存储默认纹理坐标属性的名称。
返回默认纹理坐标属性的名称:“vertexTexCoord”。
访问函数:
| QString | defaultTextureCoordinateAttributeName() | [see note below] |
注意:此 函数可通过元对象系统以及从 QML 中调用。参见Q_INVOKABLE 。
divisor : uint
存储除数。
访问函数:
| uint | divisor() const |
| void | setDivisor(uint divisor) |
通知信号:
| void | divisorChanged(uint divisor) |
name : QString
存储名称。
访问函数:
| QString | name() const |
| void | setName(const QString &name) |
通知信号:
| void | nameChanged(const QString &name) |
vertexBaseType : VertexBaseType
存储数据类型。
访问函数:
| Qt3DCore::QAttribute::VertexBaseType | vertexBaseType() const |
| void | setVertexBaseType(Qt3DCore::QAttribute::VertexBaseType type) |
通知信号:
| void | vertexBaseTypeChanged(Qt3DCore::QAttribute::VertexBaseType vertexBaseType) |
vertexSize : uint
存储数据大小,其值只能为 1 到 4 个单位(标量和向量)、9 个单位(3×3 矩阵)或 16 个单位(4×4 矩阵)。
访问函数:
| uint | vertexSize() const |
| void | setVertexSize(uint size) |
通知信号:
| void | vertexSizeChanged(uint vertexSize) |
成员函数文档
[explicit] QAttribute::QAttribute(Qt3DCore::QNode *parent = nullptr)
使用parent 创建一个新的QAttribute。
[explicit] QAttribute::QAttribute(Qt3DCore::QBuffer *buf, Qt3DCore::QAttribute::VertexBaseType type, uint dataSize, uint count, uint offset = 0, uint stride = 0, Qt3DCore::QNode *parent = nullptr)
根据buf 中的type 、dataSize 、count 、offset 和stride ,并结合parent ,构建一个新的 QAttribute。
[explicit] QAttribute::QAttribute(Qt3DCore::QBuffer *buf, const QString &name, Qt3DCore::QAttribute::VertexBaseType type, uint dataSize, uint count, uint offset = 0, uint stride = 0, Qt3DCore::QNode *parent = nullptr)
根据type 、dataSize 、count 、offset 和stride 的buf ,结合parent ,构建一个名为name 的新 QAttribute。
[signal] void QAttribute::dataSizeChanged(uint vertexSize)
当 dataSize 发生变化时,系统会通过vertexSize 触发该信号。
[signal] void QAttribute::dataTypeChanged(Qt3DCore::QAttribute::VertexBaseType vertexBaseType)
当 dataType 发生变化时,系统会通过vertexBaseType 触发该信号。
[static invokable] QString QAttribute::defaultColorAttributeName()
QAttribute::defaultColorAttributeName 返回默认颜色属性的名称
注意:此 函数可通过元对象系统和 QML 调用。参见Q_INVOKABLE 。
注意: 这是属性 defaultColorAttributeName 的获取 函数。
[static] QString QAttribute::defaultJointIndicesAttributeName()
QAttribute::defaultJointIndicesAttributeName 返回默认关节索引属性的名称
注: 这是属性 defaultJointIndicesAttributeName 的获取 函数。
[static] QString QAttribute::defaultJointWeightsAttributeName()
QAttribute::defaultJointIndicesAttributeName 返回默认关节权重属性的名称
注意: 这是属性 defaultJointWeightsAttributeName 的获取 函数。
[static invokable] QString QAttribute::defaultNormalAttributeName()
QAttribute::defaultNormalAttributeName 返回默认法线属性的名称
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
注意: 这是属性 defaultNormalAttributeName 的获取 函数。
[static invokable] QString QAttribute::defaultPositionAttributeName()
QAttribute::defaultPositionAttributeName 返回默认位置属性的名称
注意:此 函数可通过元对象系统和 QML 调用。参见Q_INVOKABLE 。
注意: 这是属性 defaultPositionAttributeName 的获取 函数。
[static invokable] QString QAttribute::defaultTangentAttributeName()
QAttribute::defaultTangentAttributeName 返回默认切线属性的名称
注意:此 函数可通过元对象系统以及从 QML 中调用。参见Q_INVOKABLE 。
注意: 这是属性 defaultTangentAttributeName 的获取 函数。
[static] QString QAttribute::defaultTextureCoordinate1AttributeName()
QAttribute::defaultTextureCoordinate1AttributeName 返回纹理坐标第二层的默认属性名称
注: 这是属性 defaultTextureCoordinate1AttributeName 的获取 函数。
[static] QString QAttribute::defaultTextureCoordinate2AttributeName()
QAttribute::defaultTextureCoordinate2AttributeName 返回纹理坐标第三层的默认属性名称
注: 这是属性 defaultTextureCoordinate2AttributeName 的获取 函数。
[static invokable] QString QAttribute::defaultTextureCoordinateAttributeName()
QAttribute::defaultTextureCoordinateAttributeName 返回默认纹理坐标属性的名称
注意:此 函数可通过元对象系统和 QML 调用。请参阅Q_INVOKABLE 。
注意: 这是属性 defaultTextureCoordinateAttributeName的获取 函数。
© 2026 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.