Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt3D (C++) 2D Text (overlay) on top of Qt3DWindow
QtWS25 Last Chance

Qt3D (C++) 2D Text (overlay) on top of Qt3DWindow

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 915 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
    panicq
    wrote on last edited by panicq
    #1

    Hi,

    First I'm new to the Qt3D framework.
    I'm trying to put 2D text on top of a Qt3DWindow or the widget created from it. I tried multiple unsuccessful approaches and hope you can give me some clues as there is very few information and forum posts about that.

    For now I've tried to:

    • Use the QText2DEntity class. But it's actually creating a text in 3D space, which I don't want, I want a simple text on top of the 3D view.
    • Create a QLabel and raising it above the QWidget (using the raise() method) returned from the createWindowContainer(my3DWindow).
    • Using the paintEvent and QPainter.

    Now a thing that I didn't tried would be to create another viewport with an orthographic camera, and rendering a QText2DEntity. Is this a proper way to do that using this framework ? If so could you give me some pointers on which classes I should take a look at ?

    I would rather prefer to be able to draw widgets on top as I could use other components (ie: sliders, buttons).

    Thank you in advance !

    kshegunovK 1 Reply Last reply
    0
    • P panicq

      Hi,

      First I'm new to the Qt3D framework.
      I'm trying to put 2D text on top of a Qt3DWindow or the widget created from it. I tried multiple unsuccessful approaches and hope you can give me some clues as there is very few information and forum posts about that.

      For now I've tried to:

      • Use the QText2DEntity class. But it's actually creating a text in 3D space, which I don't want, I want a simple text on top of the 3D view.
      • Create a QLabel and raising it above the QWidget (using the raise() method) returned from the createWindowContainer(my3DWindow).
      • Using the paintEvent and QPainter.

      Now a thing that I didn't tried would be to create another viewport with an orthographic camera, and rendering a QText2DEntity. Is this a proper way to do that using this framework ? If so could you give me some pointers on which classes I should take a look at ?

      I would rather prefer to be able to draw widgets on top as I could use other components (ie: sliders, buttons).

      Thank you in advance !

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      Your best bet is to use what comes from the Qt3D module. Other options are to embed a QML view inside the widget and use its elements to overlay over the window. The problem is that the Qt3D engine brings up a scene graph tree that is going to repaint the window, if you try to overlay something widget over it. It's a syncing issue, which ain't trivial to solve. On the other hand if you stick to QML, Qt3D integrates into the QML scene graph and it works properly. So in conclusion I suggest you use QML for that purpose, or stick with Qt3D's 2D primitives.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      1
      • P Offline
        P Offline
        panicq
        wrote on last edited by
        #3

        Okay thanks for the insights unfortunately I'm not very familiar with QML. Can you elaborate more on what Qt3D's 2D primitives are?

        kshegunovK 1 Reply Last reply
        0
        • P panicq

          Okay thanks for the insights unfortunately I'm not very familiar with QML. Can you elaborate more on what Qt3D's 2D primitives are?

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by kshegunov
          #4

          That'd be QMesh with a properly oriented quad (i.e. QPlaneMesh) + a texture and QText2DEntity. I don't believe there's much else.

          PS. Another thing that came to mind is to use native widgets for the overlay, but that can be really costly if there are many.

          Read and abide by the Qt Code of Conduct

          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