Solved How can QOpenGLWidget be used in QML/QQuickView?
-
-
Hi,
You might want to put some more information in your post.
-
@SGaist
Is there any way to import into QML/QQuickView for use?Is it ok to qmlRegisterType this QOpenglWidget and import it into QML?
-
@mirro
Hi
Ehh
QQuickWidget or QOpenglWidget is used to have QML/openGl in QWidget app.QML already uses openGL and QQuickWidget would be pointless since its already QML
so can you please explain what you want from this ? -
@mrjj
My plan is that QOpenGLWidget will integrate OSG and then import QOpenGLWidget into QML for display...Is it ok to qmlRegisterType this QOpenglWidget and import it into QML?
-
Hi
Im not sure that will work but just try it :)
It can maximum crash hard.But i think something like this is a better way
https://forum.qt.io/topic/30707/demo-integrating-openscenegraph-with-qt-quick -
@mrjj osgQtQuick 2.0
I find osgQtQuick 2.0 to be relatively crude compared to osgQT for QOpenglWidget...https://github.com/openscenegraph/osgQt
Is there another way to import QOpengLWidgets into QML display?
-
@mirro said in How can QOpenGLWidget be used in QML/QQuickView?:
Is there another way to import QOpengLWidgets into QML display?
I don't know if it will work as QML scenegraph might not support it.
But just try it.
https://forum.qt.io/topic/63057/using-a-qt-5-widget-within-a-qml-applicationand see if it will render as it should.
It if doesnt work, it will most likely just render black or simuliar so i would just test it out.
And please report back if it works or not :=) -
@mrjj
https://forum.qt.io/topic/63057/using-a-qt-5-widget-within-a-qml-application/4
I tested it and it doesn't work. It is possible that the initialization rendering mechanism is inconsistent.QOpenGLWidget rendering mechanism is the same as QML, I don't know why QOpenGLWidget can't be embedded in QML.
-
Ok. I didn't think it would as its not designed to be used that way.
But we could have been lucky. -
This is actually a big problem for me too.
"QML uses OpenGL so this would be pointless" No, it does not. It can use OpenGL, Vulkan, Software rendering, or whatever is on the system.
Also, the OP is clearly asking to be able to use the OpenGL functionality such as glClearColor() in a QQuickView.... not just the standard 2d QPainter.
I have been trying the QSGRenderNode option. It is great if you just want to do whatever is in the Qt examples.... but say you wanted to use a 3rd party renderer, which requires some initialization with a valid OpenGL context BEFORE instantiating the quickview and SHARING this context with other views? then you are out of luck.
It seems to me the only option to get this 3rd party rendering working so far is in a QOpenglWidget, and sharing that widget's context to another...
But to do this in QML? Please can someone explain?
A bit rubbish if you can only do advanced opengl stuff in a widgets style application....
-
@SamH
Not sure if this will help https://www.youtube.com/watch?v=FamAKvkfzxM I have not seen all of the video, but maybe thats what your looking for ? Personally I did OpenGL stuff in qml doing the Scene Graph - OpenGL Under QML example approach, but I was not using third party rendering. Also it was a bit of a paint having to split all the logic between a object and object rendered, a bit quirky to say the least. Now I am done with OpenGL. Vulkan, and Metal have appeard, Apple is deprecating Opengl, so I'm migrating all my stuff to Quick3D, I find it a joy to use, and it is powerfull enought, I can use shaders and all that stuff