Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. OpenGL and qml
Qt 6.12 LTS is out! See what's new in the release blog

OpenGL and qml

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 2.0k 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.
  • C Offline
    C Offline
    Carolinabustillo
    wrote on last edited by
    #1

    Hi! I want to draw and object and then import it to qml, as the logic app is done in qml. I have read that to use OpenGL I can use Openglwidget or Openglwindow. I have tried which would be better to import to qml but I have found nothing. Someone know which one would be better to use?

    1 Reply Last reply
    0
    • timdayT Offline
      timdayT Offline
      timday
      wrote on last edited by
      #2

      I don't really understand what you're trying to do, but when I want to use some C++ & OpenGL code within a QML app, then I put the code in a QQuickFramebufferObject subclass and register the type with qmlRegisterType (and the app QML is hosted in a QQuickView).

      Note that QQuickFramebufferObject is a little tricky to use due to the need to separate out a QQuickFramebufferObject::Renderer and copy any needed state over to it to support QSG's separate render thread. Don't be tempted to take shortcuts, your code will crash.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Carolinabustillo
        wrote on last edited by
        #3

        @timday Hi! thank you for answering me. I'm new to Qt and I don't really know much so I've searching about what you told and I have come across this example
        http://doc.qt.io/qt-5/qtquick-scenegraph-openglunderqml-example.html
        It's not exactly what you said but I don't find any other examples... Do you know some?
        What I meant in my previous post is that I have an .obj that I want to draw, so I have created a class to read it and then a class to render it. What I didn't know was if it was better to put:

        class Renderingwindow : public QOpenGLWindow,
                      protected QOpenGLFunctions
        

        or using QopenglWidget. Reading what you said maybe it isn't possible to do it my way and I have to try using QQuickFramebufferobject.

        timdayT 1 Reply Last reply
        0
        • C Carolinabustillo

          @timday Hi! thank you for answering me. I'm new to Qt and I don't really know much so I've searching about what you told and I have come across this example
          http://doc.qt.io/qt-5/qtquick-scenegraph-openglunderqml-example.html
          It's not exactly what you said but I don't find any other examples... Do you know some?
          What I meant in my previous post is that I have an .obj that I want to draw, so I have created a class to read it and then a class to render it. What I didn't know was if it was better to put:

          class Renderingwindow : public QOpenGLWindow,
                        protected QOpenGLFunctions
          

          or using QopenglWidget. Reading what you said maybe it isn't possible to do it my way and I have to try using QQuickFramebufferobject.

          timdayT Offline
          timdayT Offline
          timday
          wrote on last edited by
          #4

          @Carolinabustillo Hmmm I'd have said that was the old and a bit limited way of doing things in early versions of Qt5 before QQuickFramebufferObject came along. See http://blog.qt.io/blog/2015/05/11/integrating-custom-opengl-rendering-with-qt-quick-via-qquickframebufferobject/ for a more modern and flexible approach (or at least I find it works for me better). I think there are a couple of examples linked from the "Mixing Scene Graph and OpenGL" section of http://doc.qt.io/qt-5/qtquick-visualcanvas-scenegraph.html

          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
          • Unsolved