I’m trying to integrate VTK9.1 in a QML project. I’m using Qt6.2. The integration seems to be straight forward at first but then I realized that the VTK item is no drawn on the correct layer as it shoud in QML. VTK is always in the far background. I’m not able to draw any QML stuff on top of VTK. To illustrate this I modified TestQQuickVTKREnderItem.qml. I simply added a semi transparent magenta rectangle before the VTKRenderWindow. This way if it follow the QML standard, the magenta rectangle must be behind the VTK view. But it is display on top of VTK window.
Has anyone experienced this kind of issue. Is there any work around to avoid this isssue ? Am I missing something ?
I believe you may not be declaring your rectangle at the right place in your QML. This is counter intuitive, but in QML, a sibling declared below another sibling will be drawn on top. From QML doc:
Qt Quick items use a recursive drawing algorithm for determining which items are drawn on top in case of collisions. In general items are drawn on top of their parent items, in the order they were created (or specified in the QML file).
This last bold part I take to mean that elements are drawn according to their order of declaration if they are located at the same level of the QML parent/child hierarchy.
If you look at the image provided in the doc, you will see that the blue rectangle, declared at the bottom, is on top of the green rectangle, declared above.
In the example you’re providing, you’re declaring your rectangle before the VTKRenderItem.
Yes exactly, as the rectangle is declared before the VTKRenderWindow and VTKRenderItem, it should be behind VTK. But it result with a rectangle beeing on top of VTK. I would wait to get that result if the rectangle was declared after the VTK items.
Yes, this is an obvious mistake. The current version of GUISupportQtQuick connects to a wrong signal. Instead of override updatePaintNode() provided by QQuickItem. VTK currently only draws at the bottom of the QT Scene Graph, which makes it difficult to use. You either wait for VTK to provide a new implementation, or refer to the documentation of the QT scene graph, inherit a QQuickItem yourself, override updatePaintNode() and render the vtkWindow into a QSGRenderNode.
Great. One problem I had with the VTK version is that vtkHardwareSelector does not work when handling widget events similar with https://gitlab.kitware.com/vtk/vtk/-/issues/18409. Let me know of your progress. Thank you!
I am currently developing a Windows application using Qt 6.6.1 and VTK 9.3.0, and have successfully integrated your QQuickVTKItem class into my project.
However, I am encountering a challenge regarding the smoothness of screen transitions.
There is noticeable stuttering when manipulating the camera.
I have also observed this issue in a modified version of an example you provided, which was simply designed to load a single PLY file.
When employing the deprecated QQuickVTKRenderItem and QQuickVTKRenderWindow in the same environment, the application operates smoothly without any stuttering.
Could you please let me know if you are aware of this issue?
Additionally, I would be interested to know which version of Qt you used during your development.
Any advice or suggestions you could provide on resolving this problem would be immensely appreciated.