OpenGL rendering for a QML element

I have a QML file that contains a layout of QML elements, and now I want one of these elements to be QGLWidget. that is, I want to display a specific QML element.

Does anyone know how to do this?

+6
source share
1 answer

The easiest way, I suppose, is to provide QML with a new custom component implemented in C ++. I could not find anything ready.

You can subclass QDeclarativeItem and implement your OpenGL code in the paint function after using QPainter :: beginNative () . After that, you can "export" your new custom element to QML this way . This is pretty simple and should work, but you need to configure the QDeclarativeView viewport as a QGLWidget, something like this:

QDeclarativeView view; // This is needed because OpenGL viewport doesn't support partial updates. view.setViewportUpdateMode(QGraphicsView::FullViewportUpdateMode); view.setViewport(new QGLWidget); 

or you will have to use the opengl graphics system for the entire application. Another way is QML / 3D .

This stream will provide you with other information.

+3
source

Source: https://habr.com/ru/post/899313/


All Articles