Solved 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!
-
Maybe this can help you: https://doc.qt.io/qt-5.10/qt3dextras-qtext2dentity.html
-
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(); text->setParent(m_rootEntity); auto *textMaterial = new Qt3DExtras::QPhongMaterial(m_rootEntity); textMaterial->setDiffuse(QColor(0,100,0)); auto *textTransform = new Qt3DCore::QTransform(); textTransform->setTranslation(QVector3D(x, y, z)); textTransform->setScale(2.5f); textMesh = new Qt3DExtras::QExtrudedTextMesh(); textMesh->setText(s); textMesh->setDepth(.01f); }