本页内容

Qt3DRender::QPickEvent Class

class Qt3DRender::QPickEvent

QPickEvent 类用于存储对象被选中时的信息。更多内容...

头文件: #include <qpickevent.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3drender)
target_link_libraries(mytarget PRIVATE Qt6::3drender)
qmake: QT += 3drender
在 QML 中: PickEvent
继承自: QObject
被继承类:

Qt3DRender::QPickLineEvent、Qt3DRender::QPickPointEvent 以及Qt3DRender::QPickTriangleEvent

状态: 已弃用

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

公共类型

enum Buttons { LeftButton, RightButton, MiddleButton, BackButton, NoButton }
enum Modifiers { NoModifier, ShiftModifier, ControlModifier, AltModifier, MetaModifier, KeypadModifier }

属性

公共函数

QPickEvent()
QPickEvent(const QPointF &position, const QVector3D &intersection, const QVector3D &localIntersection, float distance)
QPickEvent(const QPointF &position, const QVector3D &worldIntersection, const QVector3D &localIntersection, float distance, Qt3DRender::QPickEvent::Buttons button, int buttons, int modifiers)
Qt3DRender::QPickEvent::Buttons button() const
int buttons() const
float distance() const
Qt3DCore::QEntity *entity() const
bool isAccepted() const
QVector3D localIntersection() const
int modifiers() const
QPointF position() const
Qt3DRender::QViewport *viewport() const
QVector3D worldIntersection() const

公共槽位

void setAccepted(bool accepted)

信号

void acceptedChanged(bool accepted)

详细说明

在QObjectPicker 组件的大多数信号中,当选择操作成功时,该值会作为参数接收。

另请参阅 QPickingSettings 、QPickTriangleEvent 和QObjectPicker 。

成员类型文档

enum QPickEvent::Buttons

常数值
Qt3DRender::QPickEvent::LeftButtonQt::LeftButton
Qt3DRender::QPickEvent::RightButtonQt::RightButton
Qt3DRender::QPickEvent::MiddleButtonQt::MiddleButton
Qt3DRender::QPickEvent::BackButtonQt::BackButton
Qt3DRender::QPickEvent::NoButtonQt::NoButton

enum QPickEvent::Modifiers

常数值
Qt3DRender::QPickEvent::NoModifierQt::NoModifier
Qt3DRender::QPickEvent::ShiftModifierQt::ShiftModifier
Qt3DRender::QPickEvent::ControlModifierQt::ControlModifier
Qt3DRender::QPickEvent::AltModifierQt::AltModifier
Qt3DRender::QPickEvent::MetaModifierQt::MetaModifier
Qt3DRender::QPickEvent::KeypadModifierQt::KeypadModifier

属性文档

accepted : bool

指定事件是否已被接受

访问函数:

bool isAccepted() const
void setAccepted(bool accepted)

通知信号:

void acceptedChanged(bool accepted)

[read-only] button : const Qt3DRender::QPickEvent::Buttons

指定触发该事件的鼠标按钮

访问函数:

Qt3DRender::QPickEvent::Buttons button() const

[read-only] buttons : const int

指定该事件中鼠标按钮的状态

访问函数:

int buttons() const

[read-only] distance : const float

指定命中点到摄像机的距离

访问函数:

float distance() const

[read-only] entity : Qt3DCore::QEntity* const

被选中的几何体所属的实体。

如果对象选择器未附加到场景图中的叶节点上,此属性有助于确定实际被选中的子实体是哪一个。

访问函数:

Qt3DCore::QEntity *entity() const

[read-only] localIntersection : const QVector3D

指定在所选实体的本地坐标系中命中点的坐标

访问函数:

QVector3D localIntersection() const

[read-only] modifiers : const int

指定该事件中鼠标按钮的状态

访问函数:

int modifiers() const

[read-only] position : const QPointF

指定鼠标相对于渲染区域(窗口或快捷项)的位置

访问函数:

QPointF position() const

[read-only] viewport : Qt3DRender::QViewport* const

该事件的源视口。空值表示该事件源自一个不包含 QViewport 的帧图分支。如果某个帧图分支中存在“视口嵌套视口”的情况,则该属性将包含叶子视口。

访问函数:

Qt3DRender::QViewport *viewport() const

[read-only] worldIntersection : const QVector3D

指定世界坐标系中命中点的坐标

访问函数:

QVector3D worldIntersection() const

成员函数文档

QPickEvent::QPickEvent()

创建一个新的 QPickEvent。

QPickEvent::QPickEvent(const QPointF &position, const QVector3D &intersection, const QVector3D &localIntersection, float distance)

使用给定的参数创建一个新的 QPickEvent:position 、intersection 、localIntersection 和distance

QPickEvent::QPickEvent(const QPointF &position, const QVector3D &worldIntersection, const QVector3D &localIntersection, float distance, Qt3DRender::QPickEvent::Buttons button, int buttons, int modifiers)

使用给定的参数构建一个新的 QPickEvent:position 、worldIntersection 、localIntersection 、distance 、button 、buttons 以及modifiers

Qt3DRender::QPickEvent::Buttons QPickEvent::button() const

QPickEvent::button 返回触发该事件的鼠标按钮

注意: 这是属性 button 的获取 函数。

int QPickEvent::buttons() const

QPickEvent::buttons 返回一个位域,用于检查可能伴随选择事件的鼠标按钮。

注意: 这是属性 buttons 的获取 函数。

float QPickEvent::distance() const

QPickEvent::distance 返回相机到拾取点的距离

注意: 这是距离属性的获取 函数。

bool QPickEvent::isAccepted() const

QPickEvent::isAccepted 如果事件已被接受,则返回 true

注意: 这是属性accepted 的获取 函数。

QVector3D QPickEvent::localIntersection() const

QPickEvent::localIntersection 返回被选中实体在本地坐标系中的命中坐标

注: 这是属性 localIntersection 的获取 函数。

int QPickEvent::modifiers() const

QPickEvent::modifiers 返回一个位域,用于检查可能伴随选择事件出现的键盘修饰键。

注意: 这是属性 modifiers 的获取 函数。

QPointF QPickEvent::position() const

QPickEvent::position 返回拾取查询的鼠标指针坐标

注意: 这是属性 position 的获取 函数。

[slot] void QPickEvent::setAccepted(bool accepted)

QPickEvent::setAccepted 用于设置事件是否已被接受accepted

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

另请参阅 isAccepted()。

QVector3D QPickEvent::worldIntersection() const

QPickEvent::worldIntersection 返回世界坐标系中命中点的坐标

注: 这是 worldIntersection 属性的获取 函数。

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