本页内容

Qt3DExtras::QAbstractCameraController Class

class Qt3DExtras::QAbstractCameraController

QAbstractCameraController 类为相机控制器提供了基本功能。更多内容...

头文件: #include <qabstractcameracontroller.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3dextras)
target_link_libraries(mytarget PRIVATE Qt6::3dextras)
qmake: QT += 3dextras
继承自: Qt3DCore::QEntity
继承自:

Qt3DExtras::QFirstPersonCameraController 以及Qt3DExtras::QOrbitCameraController

状态: 已弃用

该类已弃用。我们强烈建议不要在新代码中使用它。

属性

公共函数

float acceleration() const
Qt3DRender::QCamera *camera() const
float deceleration() const
float linearSpeed() const
float lookSpeed() const
void setAcceleration(float acceleration)
void setCamera(Qt3DRender::QCamera *camera)
void setDeceleration(float deceleration)
void setLinearSpeed(float linearSpeed)
void setLookSpeed(float lookSpeed)

信号

void accelerationChanged(float acceleration)
void cameraChanged()
void decelerationChanged(float deceleration)
void linearSpeedChanged()
void lookSpeedChanged()

受保护函数

Qt3DInput::QKeyboardDevice *keyboardDevice() const
Qt3DInput::QMouseDevice *mouseDevice() const

私有函数

virtual void moveCamera(const Qt3DExtras::QAbstractCameraController::InputState &state, float dt) = 0

详细说明

QAbstractCameraController 用于设置并处理来自键盘、鼠标及其他设备的输入。QAbstractCameraController 是一个抽象类,本身无法被实例化。它为摄像头控制器提供了一个标准接口。

属性文档

acceleration : float

存储相机控制器的当前加速度。

访问函数:

float acceleration() const
void setAcceleration(float acceleration)

通知信号:

void accelerationChanged(float acceleration)

camera : Qt3DRender::QCamera*

保存当前控制的摄像头。

访问功能:

Qt3DRender::QCamera *camera() const
void setCamera(Qt3DRender::QCamera *camera)

通知信号:

void cameraChanged()

deceleration : float

存储相机控制器的当前减速值。

访问函数:

float deceleration() const
void setDeceleration(float deceleration)

通知信号:

void decelerationChanged(float deceleration)

linearSpeed : float

存储摄像机控制器的当前线性速度。线性速度决定了摄像机的移动速度。

默认值为10.0 。

访问函数:

float linearSpeed() const
void setLinearSpeed(float linearSpeed)

通知信号:

void linearSpeedChanged()

lookSpeed : float

保存摄像机控制器的当前视角速度。视角速度决定了摄像机水平旋转和垂直旋转的转速。

默认值为180.0 。

访问函数:

float lookSpeed() const
void setLookSpeed(float lookSpeed)

通知信号:

void lookSpeedChanged()

成员函数文档

[protected] Qt3DInput::QKeyboardDevice *QAbstractCameraController::keyboardDevice() const

提供对键盘设备的访问。

[protected] Qt3DInput::QMouseDevice *QAbstractCameraController::mouseDevice() const

提供对鼠标设备的访问。

[pure virtual private] void QAbstractCameraController::moveCamera(const Qt3DExtras::QAbstractCameraController::InputState &state, float dt)

子类必须重写此方法,以实现控制器特有的摄像机移动。state 表示输入状态,dt 表示时间步长。

每当触发帧操作时,都会调用此函数。

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