Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. How to print text with QText2DEntity?

How to print text with QText2DEntity?

Scheduled Pinned Locked Moved Solved Game Development
qt3dqtext2dentityc++qt5.9qt 5.9
4 Posts 3 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PolyGlot
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    1
    • C Offline
      C Offline
      Cute3d
      wrote on last edited by
      #2

      Hi,

      do you have already a solution? Doesn't work for me neither.

      P 1 Reply Last reply
      0
      • C Cute3d

        Hi,

        do you have already a solution? Doesn't work for me neither.

        P Offline
        P Offline
        PolyGlot
        wrote on last edited by
        #3

        @Cute3d, yes, it finally works. Idk what was wrong. Example project:https://github.com/Nonmant/Qt3DExtras-QText2DEntity-Example
        And due to god-knows-what reasons it doesn't work in debug mode. Hope, that project can help someone.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          painestiff
          Banned
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved