How to use the ImplicitPlaneWidget2 inside QML?

Hi,
I am using VTK render window inside a QML item (i.e. in a QtQuick application).
Rendering is working fine for the ImplicitPlaneWidget2 as well as mouse interaction like mouse wheel, camera rotate etc. But I can’t enable the interaction with the plane and the orientation handle. It appears that I need to use the QVTKInteractorAdapter class (https://vtk.org/doc/nightly/html/classQVTKInteractorAdapter.html) to connect QtEvent (generated from QML item) with the VTK interactor. But, I am not sure if/how should I do that.
Is there any other way to allow the QML based application to do that?

I appreciate if you could help with a code snippet.

Thanks for your help!

Hello, friend,

I suggest reading a bit about it here: https://stackoverflow.com/questions/41685872/how-to-render-programmatically-a-vtk-item-in-qml

And taking a look at these repositories for working code:


kind regards,

Paulo

Hi Paulo,
Many thanks!
Your suggestions were really helpful and I am able to display outline box and the implicitPlaneWidget2 on two QML items as you can see from the attached screenshot


For the ImplitcitPlaneWidget2, camera rotation is working fine but I am not able to select the plane and change its orientation.
How do I enable all default interaction for this widget as it resides inside the QML item?

The fact that the 3D Widget is irresponsive certainly has to do with interactors. I don’t have any experience myself with interactors in QML, but I suppose that mouse/gesture events are not finding their way from QML to the Interactor in VTK. VTK is not aware of QML, so you have to do some tweak on your part.

After some googling, I found these:

https://vtk.org/pipermail/vtk-developers/2017-May.txt (search for “Interactor” in the page)
https://android.develop-bugs.com/article/17520230/Passing+QML+events+to+C%2B%2B+or+VTK

I suggest starting from those. Also, if it’s the case, I suggest getting acquainted with VTK Interactors in pure C++ before, so you’ll understand their mechanics.

Checkout GUISupport\QtQuick\Testing\Cxx\TestQQuickVtkItem_2.cxx in this PR
https://gitlab.kitware.com/vtk/vtk/-/merge_requests/9763