Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.14.1
-
None
Description
I have a Scene3D where I dynamically add an entity which has an ObjectPicker, via this helper class' Scene3DViewHelper::addCuboid() slot:
if(!rootEntity_) return; auto cuboidEntity = new Qt3DCore::QEntity(rootEntity_); auto mat = new Qt3DExtras::QPhongMaterial(cuboidEntity); mat->setDiffuse(QColor(217, 217, 255)); auto t = new Qt3DCore::QTransform(cuboidEntity); auto mesh = new Qt3DExtras::QCuboidMesh(cuboidEntity); auto picker = new Qt3DRender::QObjectPicker(cuboidEntity); connect(picker, &Qt3DRender::QObjectPicker::clicked, [=]{ qDebug() << "c++: clicked entity" << cuboidEntity; }); mesh->setXExtent(1); mesh->setYExtent(1); mesh->setZExtent(1); cuboidEntity->addComponent(mat); cuboidEntity->addComponent(t); cuboidEntity->addComponent(mesh); cuboidEntity->addComponent(picker);
The problem is that the ObjectPicker doesn't work: I'm supposed to see the "clicked entity Qt3DCore::QEntity(0x7fa19f005300)" message on the console when I click the cuboid, but I don't see it.
If I uncomment the `cuboid0` entity, then picking works both for the `cuboid0` entity and for the dynamically created cuboid:
qml: clicked entity Qt3DCore::Quick::Quick3DEntity(0x7fa0d7c025e0) c++: clicked entity Qt3DCore::QEntity(0x7fa0d6527f10)
Note that this bug happens only when hoverEnabled is set to true.