Porting from Qt5.15.2 to Qt6.0

Hi Friends,

I have a working project using OCCT-7.5.0 and Qt-5.15.2, I am using QQuickFramebufferObject to visualize OCCT inside Qml. There are many changes in graphic stack in Qt6, but in theory, it is still possible to use OpenGL, I have updated the dependencies and i have set GraphicsApi to OpenQL, but the framebufferobject is plain white. It receives events and render is called on Renderer instance, but the screen is just white. All other Qml Items work as expected except the OCCT FBO.

Do anyone have attempted this with some success?

With deprecation of OpenGL everywhere, i am afraid my OCCT app will be in trouble in near future. I have not tried VTK, but it seems that VTK is an option. Does anyone know about some minimal working example of VTK+Qt+OCCT? 

Thanks,

Frank.

Kirill Gavrilov's picture

With deprecation of OpenGL everywhere

Where OpenGL has been deprecated (apart from Apple platforms, which is completely irrelevant problem)?

As far as I understand, Qt 6 supports OpenGL, but it is no more the only rendering backend.
Moreover, even Qt 5 has two rendering backends which could be switched in compile-time and even in run-time (on Windows platform): OpenGL and OpenGL ES.
So that when using OCCT, Qt has to be built with a single rendering backend or to force rendering backend at startup (QCoreApplication::setAttribute (Qt::AA_UseDesktopOpenGL)).


I have not tried VTK, but it seems that VTK is an option. Does anyone know about some minimal working example of VTK+Qt+OCCT? 

How VTK could help you here? VTK relies on it's own OpenGL wrappers, hence should have the same integration issues.

Frank Martinez's picture

Hi Kirill,

Thank you for your response, I already set QCoreApplication::setAttribute (Qt::AA_UseDesktopOpenGL):

QCoreApplication::setAttribute (Qt::AA_UseDesktopOpenGL);
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);

But it didn't work. What i mean by OpenGL deprecation is that Qt is moving away from OpenGL in Qt6 to native frameworks (Vulkan, Metal, DirectX) and have deprecated many OpenGL classes. For Example QQuickFramebufferObject in Qt6 documentation is marked as legacy.

Warning: This class is only functional when Qt Quick is rendering via OpenGL. It is not compatible with other graphics APIs, such as Vulkan or Metal. It should be treated as a legacy class that is only present in order to enable Qt 5 applications to function without source compatibility breaks as long as they tie themselves to OpenGL.

If you can point me to a working Qt6+OCCT+Qml example it would be infinitelly helpful.

Thank you,

Frank M.

Kirill Gavrilov's picture

I don't think Qt tries to deprecate OpenGL backend - they just tried to make architecture flexible enough to support several backends, and hence try to replace "bad" building blocks in the current design too tied in to OpenGL renderer.
This might cause some problems, however, as they do probably care more about redesigning their own GUI composer rather than on native renderers embedded into Qt applications like OCCT 3D Viewer.
But in this context OpenGL backend in Qt will unlikely suffer more than new backends based on Vulkan/Direct3d or similar - so far I don't see here any attempt to deprecate OpenGL backend.

If you will take a look onto OCCT 3D Viewer, you'll see that unlike Qt it was designed to support different graphic libraries from very old days - this is what for a Graphic3d_GraphicDriver interface.
For a long time it was implemented with OpenGL renderer (TKOpenGl toolkit) and with a proxy Direct3D renderer (TKD3DHost using OpenGL-Direct3D interop layer).
In future there will be a native Vulkan renderer (TKVulkan) - see related issue on Bugtracker.
By the way, there are also interoperability extensions for combining OpenGL+Vulkan renderers (similar to Direct3D+OpenGL interoperability extensions).

If you can point me to a working Qt6+OCCT+Qml example it would be infinitelly helpful.

Sorry, so far I haven't seen any experiments with pre-release version of Qt6.

Example QQuickFramebufferObject in Qt6 documentation is marked as legacy.

So far I can see only the following statement in documentation:

Warning: This class is only functional when Qt Quick is rendering via OpenGL. It is not compatible with other graphics APIs, such as Vulkan or Metal. It should be treated as a legacy class that is only present in order to enable Qt 5 applications to function without source compatibility breaks as long as they tie themselves to OpenGL.

As usual, it only specifies that it is incompatible with Vulkan and Metal without details upon which API is compatible.
Documentation is obviously incomplete - either references to another "better" API are missing, Qt6 deprecates the whole ability to combine their QtQuick renderer with ANY native renderer or Qt developers haven't figured out this problem yet (postponed it to Qt 6.1 or Qt 6.5).
In any case - it worth asking this question on Qt forums (as general question of interoperability with OpenGL / other native renderers with QtQuick).

Frank Martinez's picture

Thank you Kirill, I will try in the Qt Forums.