Q3DInputHandler Class

基于鼠标滚轮的基本输入处理程序。更多

Header: #include <Q3DInputHandler>
CMake: find_package(Qt6 REQUIRED COMPONENTS DataVisualization)
target_link_libraries(mytarget PRIVATE Qt6::DataVisualization)
qmake: QT += datavisualization
QtDataVisualization 1.0
在 QML 中: InputHandler3D
继承于: QAbstract3DInputHandler
继承于:

QTouch3DInputHandler

属性

公共函数

Q3DInputHandler(QObject *parent = nullptr)
virtual ~Q3DInputHandler()
bool isRotationEnabled() const
bool isSelectionEnabled() const
bool isZoomAtTargetEnabled() const
bool isZoomEnabled() const
void setRotationEnabled(bool enable)
void setSelectionEnabled(bool enable)
void setZoomAtTargetEnabled(bool enable)
void setZoomEnabled(bool enable)

重新实现的公共函数

virtual void mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos) override
virtual void mousePressEvent(QMouseEvent *event, const QPoint &mousePos) override
virtual void mouseReleaseEvent(QMouseEvent *event, const QPoint &mousePos) override
virtual void wheelEvent(QWheelEvent *event) override

信号

void rotationEnabledChanged(bool enable)
void selectionEnabledChanged(bool enable)
void zoomAtTargetEnabledChanged(bool enable)
void zoomEnabledChanged(bool enable)

详细说明

Q3DInputHandler 是用于滚轮鼠标类型输入设备的基本输入处理程序。

默认输入处理程序具有以下功能:

鼠标动作动作
按下右键拖动在为Q3DCamera 设置的限制范围内旋转图形。
左键点击选择光标下的项目,如果没有则移除选择。根据selection mode ,可能会打开辅助视图。
鼠标滚轮在为Q3DCamera 设置的允许缩放范围内放大/缩小。
当辅助视图可见时,左键单击主视图关闭辅助视图。

注: 辅助视图仅适用于Q3DBarsQ3DSurface 图形。

旋转、缩放和选择可通过该类的相应属性单独禁用。

属性文档

[since QtDataVisualization 1.2] rotationEnabled : bool

此属性表示此输入处理程序是否允许图形旋转。

默认为true

此属性在 QtDataVisualization 1.2 中引入。

访问函数:

bool isRotationEnabled() const
void setRotationEnabled(bool enable)

Notifier 信号:

void rotationEnabledChanged(bool enable)

[since QtDataVisualization 1.2] selectionEnabled : bool

此属性表示此输入处理程序是否允许从图形中进行选择。

默认为true

此属性在 QtDataVisualization 1.2 中引入。

访问函数:

bool isSelectionEnabled() const
void setSelectionEnabled(bool enable)

Notifier 信号:

void selectionEnabledChanged(bool enable)

[since QtDataVisualization 1.2] zoomAtTargetEnabled : bool

此属性表示缩放是否会改变摄像机目标,以便图形的缩放点在缩放后保持在同一位置。

默认为true

此属性在 QtDataVisualization 1.2 中引入。

访问函数:

bool isZoomAtTargetEnabled() const
void setZoomAtTargetEnabled(bool enable)

Notifier 信号:

void zoomAtTargetEnabledChanged(bool enable)

[since QtDataVisualization 1.2] zoomEnabled : bool

此属性表示此输入处理程序是否允许图形缩放。

默认为true

此属性在 QtDataVisualization 1.2 中引入。

访问函数:

bool isZoomEnabled() const
void setZoomEnabled(bool enable)

Notifier 信号:

void zoomEnabledChanged(bool enable)

成员函数文档

[explicit] Q3DInputHandler::Q3DInputHandler(QObject *parent = nullptr)

构造基本鼠标输入处理程序。可以给出一个可选的parent 参数,然后将其传递给QObject 构造函数。

[virtual noexcept] Q3DInputHandler::~Q3DInputHandler()

销毁输入处理程序。

[override virtual] void Q3DInputHandler::mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos)

重实现:QAbstract3DInputHandler::mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos)。

重载此功能可更改鼠标移动事件的处理方式。鼠标移动事件在event 中给出,鼠标位置在mousePos 中给出。

[override virtual] void Q3DInputHandler::mousePressEvent(QMouseEvent *event, const QPoint &mousePos)

重实现:QAbstract3DInputHandler::mousePressEvent(QMouseEvent *event, const QPoint &mousePos)。

重载此功能可更改鼠标按下事件的处理方式。鼠标按下事件在event 中给出,鼠标位置在mousePos 中给出。

[override virtual] void Q3DInputHandler::mouseReleaseEvent(QMouseEvent *event, const QPoint &mousePos)

重实现:QAbstract3DInputHandler::mouseReleaseEvent(QMouseEvent *event, const QPoint &mousePos)。

重载此功能可更改鼠标释放事件的处理方式。鼠标释放事件在event 中给出,鼠标位置在mousePos 中给出。

[override virtual] void Q3DInputHandler::wheelEvent(QWheelEvent *event)

重实现:QAbstract3DInputHandler::wheelEvent(QWheelEvent *event).

重载此功能可更改对车轮事件的处理。车轮事件在event 中给出。

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