QOpenGLWidget and Qt3D for Overlays



  • I have a QOpenGLWidget and I would like to draw overlays on top of it using Qt3DCore and Qt3DExtras.
    The QOpenGLWidget window works fine and my render code is in the paintGL call, but I would like to render the Qt3D objects int the same window.

    For example, how to render this torus into the QOpenGLWidget window during the paintGL call:

    // Torus shape data
    //! [0]
    m_torus = new Qt3DExtras::QTorusMesh();
    m_torus->setRadius(1.0f);
    m_torus->setMinorRadius(0.4f);
    m_torus->setRings(100);
    m_torus->setSlices(20);
    //! [0]
    
    // TorusMesh Transform
    //! [1]
    Qt3DCore::QTransform* torusTransform = new Qt3DCore::QTransform();
    torusTransform->setScale(2.0f);
    torusTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(0.0f, 1.0f, 0.0f), 25.0f));
    torusTransform->setTranslation(QVector3D(5.0f, 4.0f, 0.0f));
    //! [1]
    
    //! [2]
    Qt3DExtras::QPhongMaterial* torusMaterial = new Qt3DExtras::QPhongMaterial();
    torusMaterial->setDiffuse(QColor(QRgb(0xbeb32b)));
    //! [2]
    

    Is this possible?

    Thanks.


Log in to reply
 

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