Problem with picking when QRenderSettings::renderPolicy is set to OnDemand

  • Hi,

    I'm trying to use the QObjectPicker to select a mesh in a Qt3DWindow.
    All works as expected, but if I set the property QRenderSettings::renderPolicy to OnDemand then the signal QObjectPicker::clicked() is emitted only when the rendering is done (when something change, as says the documentation).
    Is it the normal behavior? Do I something wrong?

    I'm using the latest beta of Qt 5.9 (beta 3), on MacOSX.

    A minimal example to reproduce the problem:

    #include <QApplication>
    #include <Qt3DExtras>
    #include <Qt3DCore>
    #include <Qt3DRender>
    #include <QtDebug>
    Qt3DCore::QEntity* createPickableMeshEntity(Qt3DCore::QNode* parent)
        Qt3DCore::QEntity* const entity = new Qt3DCore::QEntity(parent);
        Qt3DExtras::QCuboidMesh* const mesh = new Qt3DExtras::QCuboidMesh(entity);
        Qt3DExtras::QPhongMaterial* const material = new Qt3DExtras::QPhongMaterial(entity);
        Qt3DRender::QObjectPicker* const picker = new Qt3DRender::QObjectPicker(entity);
        QObject::connect(picker, &Qt3DRender::QObjectPicker::clicked, [](Qt3DRender::QPickEvent*)
            qDebug() << "Cube clicked.";
        return entity;
    int main(int argc, char *argv[])
        QApplication a(argc, argv);
        Qt3DExtras::Qt3DWindow window;
        Qt3DCore::QNode root;
        Qt3DRender::QCamera* const camera = new Qt3DRender::QCamera(&root);
        Qt3DExtras::QForwardRenderer renderer;
        // If the render policy is set to Qt3DRender::QRenderSettings::Always then when the user click on the cube
        // the message "Cube clicked" is immediatly displayed as expected.
        // But with the flag Qt3DRender::QRenderSettings::OnDemand, the message will be displayed only if
        // the rendering is triggered (in this example, when I resize the window).
        return a.exec();


  • I have reported this issue on the Qt bug tracker.
    If someone is interested:

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.