I'm using Qt3D. I'm adding QObjectPicker to my 3D entities like this:
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;
}
The mouse press events are fired, and corresponding slot logs the name of pressed entity and global coordinate correctly:
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();
}
However, to my surprise, the mouse move (hover) events are not working. The following slot function is NOT logging anything. Also, when I place a debugger break-point at this slot, I see that it is NOT invoked at all:
void MyScene::handlePickerMove(Qt3DRender::QPickEvent *event)
{
qDebug() << "Hover Intersection:" << event->worldIntersection();
}
Am I missing something?
My Qt3D rendering settings are:
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());
Relates to this report.
The description of the moved
signal 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".
So this signal is not emitted on hover/mouse move, but on mouse move while pressing a mouse button.