本页内容

Qt3DAnimation::QCallbackMapping Class

class Qt3DAnimation::QCallbackMapping

允许将片段中的通道映射到回调对象的调用上。更多...

标题: #include <qcallbackmapping.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3danimation)
target_link_libraries(mytarget PRIVATE Qt6::3danimation)
qmake: QT += 3danimation
继承自: Qt3DAnimation::QAbstractChannelMapping
状态: 技术预览

该类处于技术预览阶段,内容可能会有变动。

属性

公共函数

QString channelName() const
void setCallback(int type, Qt3DAnimation::QAnimationCallback *callback, Qt3DAnimation::QAnimationCallback::Flags flags = QAnimationCallback::OnOwningThread)

公共槽位

void setChannelName(const QString &channelName)

信号

void channelNameChanged(QString channelName)

详细说明

属性文档

channelName : QString

存储回调映射的通道名称。

访问函数:

QString channelName() const
void setChannelName(const QString &channelName)

通知器信号:

void channelNameChanged(QString channelName)

成员函数文档

void QCallbackMapping::setCallback(int type, Qt3DAnimation::QAnimationCallback *callback, Qt3DAnimation::QAnimationCallback::Flags flags = QAnimationCallback::OnOwningThread)

将一个 `callback ` 对象与该通道映射相关联。

此类映射不必指定目标对象和属性名称。当设置了 `callback ` 对象后,动画值每次发生变化时,都会触发回调函数的 `valueChanged ` 方法,该方法可能在 GUI/主线程上执行,也可能直接在线程池的工作线程之一上执行。此行为由 `flags` 控制。

type 指定动画值的类型(例如,QMetaType::QVector3D 、QMetaType::QColor 或QMetaType::Float )。在对节点属性进行动画处理时,无需单独提供此参数;但在仅有一个回调函数的情况下,提供此参数则至关重要。

注意:一个 映射既可以与节点属性关联,也可以与回调函数关联。但在这种情况下,type 必须与属性的类型匹配,这一点非常重要。另请注意,对于类型为QVariant 的属性(例如 QParameter::value),type 即为存储在QVariant 中的值的类型。

注意: 在任何关联的动画器运行期间,callback 指针应保持有效。

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