How to print text with QText2DEntity?
Solved
Game Development
-
There was this question already:
Re: Qt3D: how to print text? (QText2DEntity)
And, as an only working example of usage, was this code:// camera position auto *camera = _view->camera(); camera->setPosition({ 0, 40.0f, 0 }); camera->setViewCenter({ 0, 0, 0 }); camera->setUpVector({ 0, 0, 1.0f }); camera->panAboutViewCenter(180.0f) // text auto *text2D = new Qt3DExtras::QText2DEntity(_rootEntity); text2D->setFont(QFont("monospace")); text2D->setHeight(20); text2D->setWidth(100); text2D->setText("monospace"); text2D->setColor(Qt::yellow); auto *textTransform = new Qt3DCore::QTransform(text2D); textTransform->setRotation(QQuaternion::fromAxisAndAngle({ 1, 0, 0 }, 90.0f)); textTransform->setScale(0.125f); text2D->addComponent(textTransform);
But, it's not working for me: just nothing appears. Code looks correct, so, probably, the question is about correct parameters: width, height and scale for text. I've tried but didn't reach any result.
Does anyone have any working example of this class usage?
-
This post is deleted!