本页内容

Qt3DRender::QCameraLens Class

class Qt3DRender::QCameraLens

Qt3DRender::QCameraLens 指定用于定义 3D 场景中摄像机的投影矩阵。更多内容...

头文件: #include <Qt3DRender/QCameraLens>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3drender)
target_link_libraries(mytarget PRIVATE Qt6::3drender)
qmake: QT += 3drender
在 QML 中: CameraLens
继承自: Qt3DCore::QComponent
状态: 已弃用

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

公共类型

enum ProjectionType { OrthographicProjection, PerspectiveProjection, FrustumProjection, CustomProjection }

属性

公共函数

QCameraLens(Qt3DCore::QNode *parent = nullptr)
float aspectRatio() const
float bottom() const
float exposure() const
float farPlane() const
float fieldOfView() const
float left() const
float nearPlane() const
QMatrix4x4 projectionMatrix() const
Qt3DRender::QCameraLens::ProjectionType projectionType() const
float right() const
void setFrustumProjection(float left, float right, float bottom, float top, float nearPlane, float farPlane)
void setOrthographicProjection(float left, float right, float bottom, float top, float nearPlane, float farPlane)
void setPerspectiveProjection(float fieldOfView, float aspectRatio, float nearPlane, float farPlane)
float top() const

公共槽位

void setAspectRatio(float aspectRatio)
void setBottom(float bottom)
void setExposure(float exposure)
void setFarPlane(float farPlane)
void setFieldOfView(float fieldOfView)
void setLeft(float left)
void setNearPlane(float nearPlane)
void setProjectionMatrix(const QMatrix4x4 &projectionMatrix)
void setProjectionType(Qt3DRender::QCameraLens::ProjectionType projectionType)
void setRight(float right)
void setTop(float top)

信号

void aspectRatioChanged(float aspectRatio)
void bottomChanged(float bottom)
void exposureChanged(float exposure)
void farPlaneChanged(float farPlane)
void fieldOfViewChanged(float fieldOfView)
void leftChanged(float left)
void nearPlaneChanged(float nearPlane)
void projectionMatrixChanged(const QMatrix4x4 &projectionMatrix)
void projectionTypeChanged(Qt3DRender::QCameraLens::ProjectionType projectionType)
void rightChanged(float right)
void topChanged(float top)

详细说明

成员类型文档

enum QCameraLens::ProjectionType

指定用于计算投影矩阵的Qt3DRender::QCameraLens 参数。

常量值描述
Qt3DRender::QCameraLens::OrthographicProjection0正交投影
Qt3DRender::QCameraLens::PerspectiveProjection1透视投影
Qt3DRender::QCameraLens::FrustumProjection2截锥体投影
Qt3DRender::QCameraLens::CustomProjection3自定义投影

属性文档

aspectRatio : float

保存相机镜头的当前宽高比。

注意: 如果投影类型不是Qt3DRender::QCameraLens::PerspectiveProjection ,则返回值可能未定义。

访问函数:

float aspectRatio() const
void setAspectRatio(float aspectRatio)

通知信号:

void aspectRatioChanged(float aspectRatio)

bottom : float

保存相机镜头的当前底平面。

注意: 如果投影类型为Qt3DRender::QCameraLens::PerspectiveProjection ,则返回值可能未定义。

访问函数:

float bottom() const
void setBottom(float bottom)

通知信号:

void bottomChanged(float bottom)

exposure : float

保存相机镜头的当前曝光值。

访问功能:

float exposure() const
void setExposure(float exposure)

通知信号:

void exposureChanged(float exposure)

farPlane : float

保存相机镜头当前的近平面。

访问函数:

float farPlane() const
void setFarPlane(float farPlane)

通知信号:

void farPlaneChanged(float farPlane)

fieldOfView : float

保存相机镜头的当前视场。

注意: 如果投影类型不是Qt3DRender::QCameraLens::PerspectiveProjection ,则返回值可能未定义。

访问函数:

float fieldOfView() const
void setFieldOfView(float fieldOfView)

通知信号:

void fieldOfViewChanged(float fieldOfView)

left : float

保存摄像机镜头当前的左平面。

注意: 如果投影类型为Qt3DRender::QCameraLens::PerspectiveProjection ,则返回值可能未定义。

访问函数:

float left() const
void setLeft(float left)

通知信号:

void leftChanged(float left)

nearPlane : float

保存相机镜头当前的近平面。

访问函数:

float nearPlane() const
void setNearPlane(float nearPlane)

通知信号:

void nearPlaneChanged(float nearPlane)

projectionMatrix : QMatrix4x4

存储相机镜头的当前投影矩阵。

访问函数:

QMatrix4x4 projectionMatrix() const
void setProjectionMatrix(const QMatrix4x4 &projectionMatrix)

通知信号:

void projectionMatrixChanged(const QMatrix4x4 &projectionMatrix)

projectionType : ProjectionType

存储相机投影的类型。

访问函数:

Qt3DRender::QCameraLens::ProjectionType projectionType() const
void setProjectionType(Qt3DRender::QCameraLens::ProjectionType projectionType)

通知信号:

void projectionTypeChanged(Qt3DRender::QCameraLens::ProjectionType projectionType)

另请参阅 Qt3DRender::QCameraLens::ProjectionType 。

right : float

保存摄像机镜头的当前右平面。

注意: 如果投影类型为Qt3DRender::QCameraLens::PerspectiveProjection ,则返回值可能未定义。

访问函数:

float right() const
void setRight(float right)

通知信号:

void rightChanged(float right)

top : float

保存相机镜头当前的顶层平面。

注意: 如果投影类型为Qt3DRender::QCameraLens::PerspectiveProjection ,则返回值可能未定义。

访问函数:

float top() const
void setTop(float top)

通知信号:

void topChanged(float top)

成员函数文档

[explicit] QCameraLens::QCameraLens(Qt3DCore::QNode *parent = nullptr)

根据给定的参数构建一个 QCameraLens 对象parent

[slot] void QCameraLens::setAspectRatio(float aspectRatio)

将投影的宽高比设置为aspectRatio 。这将触发投影矩阵的更新。

注意: 如果投影类型不是Qt3DRender::QCameraLens::PerspectiveProjection ,则此操作 无效。

注意: 这是属性aspectRatio 的设置 函数。

另请参阅 aspectRatio()。

[slot] void QCameraLens::setBottom(float bottom)

将投影的底部窗口坐标设置为bottom 。这将触发投影矩阵的更新。

注意: 如果投影类型为Qt3DRender::QCameraLens::PerspectiveProjection ,则此操作 无效。

注意: 此为属性 `bottom`的设置 函数。

另请参阅 bottom()。

[slot] void QCameraLens::setExposure(float exposure)

设置相机镜头的exposure

注意: 这是属性exposure 的设置 函数。

另请参阅 exposure()。

[slot] void QCameraLens::setFarPlane(float farPlane)

将投影的远平面设置为farPlane 。这将触发投影矩阵的更新。

注意: 这是属性farPlane 的设置 函数。

另请参阅 farPlane()。

[slot] void QCameraLens::setFieldOfView(float fieldOfView)

将投影的视场角设置为fieldOfView 度。这将触发投影矩阵的更新。

注意: 如果投影类型不是Qt3DRender::QCameraLens::PerspectiveProjection ,则此操作 无效。

注意: 这是属性fieldOfView 的设置 函数。

另请参阅 fieldOfView()。

void QCameraLens::setFrustumProjection(float left, float right, float bottom, float top, float nearPlane, float farPlane)

定义了一种基于left 、right 、bottom 、top 、nearPlane 、farPlane 的正射投影。

[slot] void QCameraLens::setLeft(float left)

将投影的左下角窗口坐标设置为left 。这将触发投影矩阵的更新。

注意: 如果投影类型为Qt3DRender::QCameraLens::PerspectiveProjection ,则此操作 无效。

注意: 这是属性left 的设置 函数。

另请参阅 left()。

[slot] void QCameraLens::setNearPlane(float nearPlane)

将投影的近平面设置为nearPlane 。这将触发投影矩阵的更新。

注意: 这是属性nearPlane 的设置 函数。

另请参阅 nearPlane()。

void QCameraLens::setOrthographicProjection(float left, float right, float bottom, float top, float nearPlane, float farPlane)

定义了一种基于left 、right 、bottom 、top 、nearPlane 、farPlane 的正射投影。

void QCameraLens::setPerspectiveProjection(float fieldOfView, float aspectRatio, float nearPlane, float farPlane)

定义了一种基于fieldOfView 、aspectRatio 、nearPlane 、farPlane 的透视投影。

[slot] void QCameraLens::setProjectionMatrix(const QMatrix4x4 &projectionMatrix)

将项目矩阵设置为projectionMatrix 。

注意:这将 把投影类型设置为Qt3DRender::QCameraLens::CustomProjection ,因此会忽略可能已指定的所有其他相机参数。

注意: 这是属性projectionMatrix 的设置 函数。

另请参阅 projectionMatrix()。

[slot] void QCameraLens::setProjectionType(Qt3DRender::QCameraLens::ProjectionType projectionType)

设置镜头的投影类型projectionType 。

注意:Qt3DRender ::QCameraLens::Frustum 和Qt3DRender::QCameraLens::PerspectiveProjection 是指定同一投影的两种不同方式。

注意: 属性projectionType 的设置 函数。

另请参阅 projectionType()。

[slot] void QCameraLens::setRight(float right)

将投影的右上角窗口坐标设置为right 。这将触发投影矩阵的更新。

注意: 如果投影类型为Qt3DRender::QCameraLens::PerspectiveProjection ,则此操作 无效。

注意: 这是属性 `right`的设置 函数。

另请参阅 right()。

[slot] void QCameraLens::setTop(float top)

将投影的顶部窗口坐标设置为top 。这将触发投影矩阵的更新。

注意: 如果投影类型为Qt3DRender::QCameraLens::PerspectiveProjection ,则此操作 无效。

注意: 这是属性 `top`的设置 函数。

另请参阅 top()。

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