Important: Please read the Qt Code of Conduct -

How to add text / label in Qt3D / Qt3DWindow

  • Hi all,

    I've a Qt3D window with some sphere meshes displayed.

    Is there any way to add some text labels on each of these spheres?

    Thank you in advance and have a good weekend!

  • It's solved. For anyone interested below is my solution.

    void SceneModifier::addLabel(int label, float x, float y, float z)
        QString s = QString::number(label);
            // Set label's text
           // auto *text = new Qt3DCore::QEntity(m_rootEntity);
        text = new Qt3DCore::QEntity();
            auto *textMaterial = new Qt3DExtras::QPhongMaterial(m_rootEntity);
            auto *textTransform = new Qt3DCore::QTransform();
            textTransform->setTranslation(QVector3D(x, y, z));
            textMesh = new Qt3DExtras::QExtrudedTextMesh();

Log in to reply