Correction. I do not why. But my proposal no more works. But I found another way that seems to work. In fact the QDiffuseSpecularMaterial that we are supposed to use (other materials are deprecated), disable the depth buffer. So, this is a working code to force the enable (create a new effect does not work):
Qt3DRender::QEffect *effect = material->effect();
if (effect)
{
for (Qt3DRender::QTechnique* currentTechnique : effect->techniques())
{
for (Qt3DRender::QRenderPass * currentPass : currentTechnique->renderPasses())
{
for (Qt3DRender::QRenderState * currentState : currentPass->renderStates())
{
if (dynamic_cast<Qt3DRender::QNoDepthMask *>(currentState))
{
currentPass->removeRenderState(currentState);
Qt3DRender::QDepthTest* depthTest = new Qt3DRender::QDepthTest;
depthTest ->setDepthFunction(Qt3DRender::QDepthTest::Less);
currentPass->addRenderState(depthTest);
break;
}
}
}
}
}
Warning: if you have fully transparent (alpha = 0) objects, the test fails. So the objects behind the invisible one are not displayed.