触发鼠标按下事件但不触发鼠标移动事件

Mouse-pressed event is fired but mouse-moved event is not

我正在使用 Qt3D。我将 QObjectPicker 添加到我的 3D 实体中,如下所示:

Qt3DRender::QObjectPicker *MyScene::createObjectPickerForEntity(Qt3DCore::QEntity *entity)
{
    if (!entity)
        return nullptr;

    picker = new Qt3DRender::QObjectPicker(entity);
    picker->setHoverEnabled(true); // I set this correctly
    picker->setDragEnabled(true); // Also required!
    picker->setObjectName(QStringLiteral("__internal ") + entity->objectName());
    entity->addComponent(picker);
    connect(picker, &Qt3DRender::QObjectPicker::pressed, this, &MyScene::handlePickerPress);
    connect(picker, &Qt3DRender::QObjectPicker::moved, this, &MyScene::handlePickerMove);

    return picker;
}

鼠标按下事件被触发,对应的slot记录被按下的实体名称和全局坐标正确:

void MyScene::handlePickerPress(Qt3DRender::QPickEvent *event)
{
    Qt3DCore::QEntity *pressedEntity = qobject_cast<Qt3DCore::QEntity *>(sender()->parent());
    if (!pressedEntity && !pressedEntity->isEnabled())
        return;

    qDebug() << "Pressed Entity Name: "<< pressedEntity->objectName();
    qDebug() << "Global Coord: " << event->worldIntersection();
}

然而,令我惊讶的是,鼠标移动(悬停)事件不起作用。以下槽函数不记录任何内容。另外,当我在这个插槽中放置一个调试器断点时,我发现它根本没有被调用:

void MyScene::handlePickerMove(Qt3DRender::QPickEvent *event)
{
    qDebug() << "Hover Intersection:" << event->worldIntersection();
}

我是不是漏掉了什么?


我的 Qt3D 渲染设置是:

m_renderSettings = new Qt3DRender::QRenderSettings();
m_renderSettings->pickingSettings()->setPickMethod(Qt3DRender::QPickingSettings::TrianglePicking);
m_renderSettings->pickingSettings()->setPickResultMode(Qt3DRender::QPickingSettings::NearestPick);
m_renderSettings->setObjectName(QStringLiteral("__internal Scene frame graph"));
m_renderer = new Qt3DExtras::QForwardRenderer();
m_renderer->setClearColor(QColor("#c8c8c8"));
m_renderSettings->setActiveFrameGraph(m_renderer);
m_renderSettings->setRenderPolicy(Qt3DRender::QRenderSettings::RenderPolicy::OnDemand);

m_rootEntity->addComponent(m_renderSettings);

m_rootEntity->addComponent(new Qt3DInput::QInputSettings());

更新

this report 有关。

moved 信号 says 的描述:"This signal is emitted when the bounding volume defined by the pickAttribute property intersects with a ray on a mouse move with a button pressed"。

所以这个信号不是在 hover/mouse 移动时发出的,而是在按下鼠标按钮时移动鼠标时发出的。